Tutorial by Examples: calcul

package com.example; import android.os.Bundle; import android.support.annotation.Nullable; import android.util.Log; import android.view.View; import android.view.ViewTreeObserver; public class ExampleActivity extends Activity { @Override protected void onCreate(@Nullable final ...
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { /* Exit if no second argument is found. */ if (argc != 2) { puts("Argument missing."); return EXIT_FAILURE; } size_t len = str...
Factorials can be computed at compile-time using template metaprogramming techniques. #include <iostream> template<unsigned int n> struct factorial { enum { value = n * factorial<n - 1>::value }; }; template<> struct factorial<0> { ...
Each individual CSS Selector has its own specificity value. Every selector in a sequence increases the sequence's overall specificity. Selectors fall into one of three different specificity groups: A, B and c. When multiple selector sequences select a given element, the browser uses the styles appli...
// Java: Arrays.stream(new int[] {1, 2, 3}) .map(n -> 2 * n + 1) .average() .ifPresent(System.out::println); // 5.0 // Kotlin: arrayOf(1,2,3).map { 2 * it + 1}.average().apply(::println)
Units of measure are additional type annotations that can be added to floats or integers. They can be used to verify at compile time that calculations are using units consistently. To define annotations: [<Measure>] type m // meters [<Measure>] type s // seconds [<Measure>] typ...
A common use case for wanting to calculate the frame a label will take up is for sizing table view cells appropriately. The recommended way of doing this is using the NSString method boundingRectWithSize:options:attributes:context:. options takes String drawing options: NSStringDrawingUsesLineFr...
With C++11 and higher calculations at compile time can be much easier. For example calculating the power of a given number at compile time will be following: template <typename T> constexpr T calculatePower(T value, unsigned power) { return power == 0 ? 1 : value * calculatePower(value,...
By recursion let rec sumTotal list = match list with | [] -> 0 // empty list -> return 0 | head :: tail -> head + sumTotal tail The above example says: "Look at the list, is it empty? return 0. Otherwise it is a non-empty list. So it could be [1], [1; 2], [1; 2; 3] ...
The MEDIAN function since Oracle 10g is an easy to use aggregation function: SELECT MEDIAN(SAL) FROM EMP It returns the median of the values Works on DATETIME values too. The result of MEDIAN is computed by first ordering the rows. Using N as the number of rows in the group, Oracle calcula...
The hashlib module allows creating message digest generators via the new method. These generators will turn an arbitrary string into a fixed-length digest: import hashlib h = hashlib.new('sha256') h.update(b'Nobody expects the Spanish Inquisition.') h.digest() # ==> b'.\xdf\xda\xdaVR[\x12\...
- components:fromDate: Returns a NSDateComponents object containing a given date decomposed into specified components NSCalendar *calender = [NSCalendar autoupdatingCurrentCalendar]; [calender setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; NSLog(@"%@",[calender components:NSCale...
Collections also provide you with an easy way to do simple statistical calculations. $books = [ ['title' => 'The Pragmatic Programmer', 'price' => 20], ['title' => 'Continuous Delivery', 'price' => 30], ['title' => 'The Clean Coder', 'price' => 10], ] $min = col...
One way to calculate the Big-O value of a procedure you've written is to determine which line of code runs the most times in your function, given your input size n. Once you have that number, take out all but the fastest-growing terms and get rid of the coefficents - that is the Big-O notation of yo...
The factorial of a number (denoted with !, as for instance 9!) is the multiplication of that number with the factorial of one lower. So, for instance, 9! = 9 x 8! = 9 x 8 x 7! = 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1. So in code that becomes, using recursion: long Factorial(long x) { if (x < 1...
Gray Level Co-Occurrence Matrix (Haralick et al. 1973) texture is a powerful image feature for image analysis. The glcm package provides a easy-to-use function to calculate such texutral features for RasterLayer objects in R. library(glcm) library(raster) r <- raster("C:/Program Files/R...
In molecular biology and genetics, GC-content (or guanine-cytosine content, GC% in short) is the percentage of nitrogenous bases on a DNA molecule that are either guanine or cytosine (from a possibility of four different ones, also including adenine and thymine). Using BioPython: >>> from...
var arr = [1, 2, 3, 4, 5]; var sum = arr.reduce((prev, curr) => prev + curr); console.log(sum); // Output: 15 You can also specify an initial value var arr = [1, 2, 3, 4, 5]; var sum = arr.reduce(function (previousValue, currentValue, currentIndex, array) { return previousValue + cur...
General syntax: DATEDIFF (datepart, datetime_expr1, datetime_expr2) It will return a positive number if datetime_expr is in the past relative to datetime_expr2, and a negative number otherwise. Examples DECLARE @now DATETIME2 = GETDATE(); DECLARE @oneYearAgo DATETIME2 = DATEADD(YEAR, -1, @now...
DateDiff() DateDiff() returns a Long representing the number of time intervals between two specified dates. Syntax DateDiff ( interval, date1, date2 [, firstdayofweek] [, firstweekofyear] ) interval can be any of the intervals defined in the DatePart() function date1 and date2 are the two ...

Page 1 of 3