Tutorial by Examples

There are two things you will need to know when writing a "hello world" application in Erlang: The source code is written in the erlang programming language using the text editor of your choice The application is then executed in the erlang virtual machine. In this example we will inte...
Structure data types are useful way to package related data and have them behave like a single variable. Declaring a simple struct that holds two int members: struct point { int x; int y; }; x and y are called the members (or fields) of point struct. Defining and using structs: ...
Trim is used to remove write-space at the beginning or end of selection In MSSQL there is no single TRIM() SELECT LTRIM(' Hello ') --returns 'Hello ' SELECT RTRIM(' Hello ') --returns ' Hello' SELECT LTRIM(RTRIM(' Hello ')) --returns 'Hello' MySql and Oracle SELECT TRIM(' Hello ') ...
In (standard ANSI/ISO) SQL, the operator for string concatenation is ||. This syntax is supported by all major databases except SQL Server: SELECT 'Hello' || 'World' || '!'; --returns HelloWorld! Many databases support a CONCAT function to join strings: SELECT CONCAT('Hello', 'World'); --retur...
SELECT UPPER('HelloWorld') --returns 'HELLOWORLD' SELECT LOWER('HelloWorld') --returns 'helloworld'
Syntax is: SUBSTRING ( string_expression, start, length ). Note that SQL strings are 1-indexed. SELECT SUBSTRING('Hello', 1, 2) --returns 'He' SELECT SUBSTRING('Hello', 3, 3) --returns 'llo' This is often used in conjunction with the LEN() function to get the last n characters of a string of un...
Splits a string expression using a character separator. Note that STRING_SPLIT() is a table-valued function. SELECT value FROM STRING_SPLIT('Lorem ipsum dolor sit amet.', ' '); Result: value ----- Lorem ipsum dolor sit amet.
Stuff a string into another, replacing 0 or more characters at a certain position. Note: start position is 1-indexed (you start indexing at 1, not 0). Syntax: STUFF ( character_expression , start , length , replaceWith_expression ) Example: SELECT STUFF('FooBarBaz', 4, 3, 'Hello') --returns...
SQL Server The LEN doesn't count the trailing space. SELECT LEN('Hello') -- returns 5 SELECT LEN('Hello '); -- returns 5 The DATALENGTH counts the trailing space. SELECT DATALENGTH('Hello') -- returns 5 SELECT DATALENGTH('Hello '); -- returns 6 It should be noted though, that DATALE...
Nginx is a Web server used to serve HTTP requests over the Internet. Nginx is available on Linux, Windows and other OSes as direct download, and can also be built from source. For detailed instructions see Nginx official reference. ubuntu/debian nginx stable version is available in official repo,...
Detailed instructions on getting azureservicebus set up or installed.
While the Java Date class has several constructors, you'll notice that most are deprecated. The only acceptable way of creating a Date instance directly is either by using the empty constructor or passing in a long (number of milliseconds since standard base time). Neither are handy unless you're lo...
We can provide a consumer that will be called with the multiple relevant values: C++11 template <class F> void foo(int a, int b, F consumer) { consumer(a + b, a - b, a * b, a / b); } // use is simple... ignoring some results is possible as well foo(5, 12, [](int sum, int , int , i...
// The Option type can either contain Some value or None. fn find(value: i32, slice: &[i32]) -> Option<usize> { for (index, &element) in slice.iter().enumerate() { if element == value { // Return a value (wrapped in Some). return Some(index);...
To write the traditional Hello World program in Rust, create a text file called hello.rs containing the following source code: fn main() { println!("Hello World!"); } This defines a new function called main, which takes no parameters and returns no data. This is where your progra...
Inject and reduce are different names for the same thing. In other languages these functions are often called folds (like foldl or foldr). These methods are available on every Enumerable object. Inject takes a two argument function and applies that to all of the pairs of elements in the Array. For...
Discriminated unions in F# offer a a way to define types which may hold any number of different data types. Their functionality is similar to C++ unions or VB variants, but with the additional benefit of being type safe. // define a discriminated union that can hold either a float or a string type...
Type information does not need to be included in the cases of a discriminated union. By omitting type information you can create a union that simply represents a set of choices, similar to an enum. // This union can represent any one day of the week but none of // them are tied to a specific unde...
To apply a function to every item in an array, use array_map(). This will return a new array. $array = array(1,2,3,4,5); //each array item is iterated over and gets stored in the function parameter. $newArray = array_map(function($item) { return $item + 1; }, $array); $newArray now is a...
You can access the elements of an array by their indices. Array index numbering starts at 0. %w(a b c)[0] # => 'a' %w(a b c)[1] # => 'b' You can crop an array using range %w(a b c d)[1..2] # => ['b', 'c'] (indices from 1 to 2, including the 2) %w(a b c d)[1...2] # => ['b'] (indic...

Page 136 of 1336