Tutorial by Examples: c

This is a type system extension that allows types that are existentially quantified, or, in other words, have type variables that only get instantiated at runtime†. A value of existential type is similar to an abstract-base-class reference in OO languages: you don't know the exact type in contains,...
The following expressions are sequenced: a && b a || b a , b a ? b : c for ( a ; b ; c ) { ... } In all cases, the expression a is fully evaluated and all side effects are applied before either b or c are evaluated. In the fourth case, only one of b or c will be evaluated. In the l...
C11 The following expressions are unsequenced: a + b; a - b; a * b; a / b; a % b; a & b; a | b; In the above examples, the expression a may be evaluated before or after the expression b, b may be evaluated before a, or they may even be intermixed if they correspond to several instruct...
With this fundamental workflow model, a master branch contains all active development. Contributors will need to be especially sure they pull the latest changes before continuing development, for this branch will be changing rapidly. Everyone has access to this repo and can commit changes right to t...
Database transactions ensure that a set of data changes will only be made permanent if every statement is successful. Any query or code failure during a transaction can be caught and you then have the option to roll back the attempted changes. PDO provides simple methods for beginning, committing,...
In this example, documentation for the local function baz (defined in foo.m) can be accessed either by the resulting link in help foo, or directly through help foo>baz. function bar = foo %This is documentation for FOO. % See also foo>baz % This wont be printed, because there is a line w...
In C++, sequences of characters are represented by specializing the std::basic_string class with a native character type. The two major collections defined by the standard library are std::string and std::wstring: std::string is built with elements of type char std::wstring is built with e...
Strings in Elixir are "binaries". However, in Erlang code, strings are traditionally "char lists", so when calling Erlang functions, you may have to use char lists instead of regular Elixir strings. While regular strings are written using double quotes ", char lists are wr...
Lists in Elixir are linked lists. This means that each item in a list consists of a value, followed by a pointer to the next item in the list. This is implemented in Elixir using cons cells. Cons cells are simple data structures with a "left" and a "right" value, or a "he...
As seen in "Lambda Functions", functions can take other functions as a parameter. The "function type" which you'll need to declare functions which take other functions is as follows: # Takes no parameters and returns anything () -> Any? # Takes a string and an integer a...
Lambda functions are anonymous functions which are usually created during a function call to act as a function parameter. They are declared by surrounding expressions with {braces} - if arguments are needed, these are put before an arrow ->. { name: String -> "Your name is $name&q...
We can reference a function without actually calling it by prefixing the function's name with ::. This can then be passed to a function which accepts some other function as a parameter. fun addTwo(x: Int) = x + 2 listOf(1, 2, 3, 4).map(::addTwo) # => [3, 4, 5, 6] Functions without a receiv...
Functions are declared using the fun keyword, followed by a function name and any parameters. You can also specify the return type of a function, which defaults to Unit. The body of the function is enclosed in braces {}. If the return type is other than Unit, the body must issue a return statement ...
If a function contains just one expression, we can omit the brace brackets and use an equals instead, like a variable assignment. The result of the expression is returned automatically. fun sayMyName(name: String): String = "Your name is $name"
Functions can be declared inline using the inline prefix, and in this case they act like macros in C - rather than being called, they are replaced by the function's body code at compile time. This can lead to performance benefits in some circumstances, mainly where lambdas are used as function param...
The following will create dist/output.jar from the source code in src and the libraries in lib, and will use src/Main.java as the main class. <project name="Project" default="main" basedir="."> <property name="src.dir" value="src&quot...
Django's default authentication works on username and password fields. Email authentication backend will authenticate users based on email and password. from django.contrib.auth import get_user_model class EmailBackend(object): """ Custom Email Backend to perform authent...
iex(1)> recompile Compiling 1 file (.ex) :ok
iex(1)> h List.last def last(list) Returns the last element in list or nil if list is empty. Examples ┃ iex> List.last([]) ┃ nil ┃ ┃ iex> List.last([1]) ┃ 1 ┃ ┃ iex> List.last([1, 2, 3]) ┃ 3
iex(1)> 1 + 1 2 iex(2)> v 2 iex(3)> 1 + v 3 See also: Get the value of a row with `v`

Page 97 of 826