Tutorial by Examples: al

C11 Queries the alignment requirement for the specified type. The alignment requirement is a positive integral power of 2 representing the number of bytes between which two objects of the type may be allocated. In C, the alignment requirement is measured in size_t. The type name may not be an inco...
Occasionally you may want to use the same tuple type in multiple places throughout your code. This can quickly get messy, especially if your tuple is complex: // Define a circle tuple by its center point and radius let unitCircle: (center: (x: CGFloat, y: CGFloat), radius: CGFloat) = ((0.0, 0.0), ...
The return statement in Bash doesn't return a value like C-functions, instead it exits the function with a return status. You can think of it as the exit status of that function. If you want to return a value from the function then send the value to stdout like this: fun() { local var="S...
Some example cases when the result is an optional. var result: AnyObject? = someMethod() switch result { case nil: print("result is nothing") case is String: print("result is a String") case _ as Double: print("result is not nil, any value that is a Dou...
Before C++17, having pointers with a value of nullptr commonly represented the absence of a value. This is a good solution for large objects that have been dynamically allocated and are already managed by pointers. However, this solution does not work well for small or primitive types such as int, w...
Before C++17, a function typically represented failure in one of several ways: A null pointer was returned. e.g. Calling a function Delegate *App::get_delegate() on an App instance that did not have a delegate would return nullptr. This is a good solution for objects that have been dynamicall...
Some C implementations permit code to write to one member of a union type then read from another in order to perform a sort of reinterpreting cast (parsing the new type as the bit representation of the old one). It is important to note however, this is not permitted by the C standard current or pas...
The apply and call methods in every function allow it to provide a custom value for this. function print() { console.log(this.toPrint); } print.apply({ toPrint: "Foo" }); // >> "Foo" print.call({ toPrint: "Foo" }); // >> "Foo" You mig...
If we have a struct like this struct Box { let name: String let thingsInside: Int } and an array of Box(es) let boxes = [ Box(name: "Box 0", thingsInside: 1), Box(name: "Box 1", thingsInside: 2), Box(name: "Box 2", thingsInside: 3), B...
Values can be given names using let: # let a = 1;; val a : int = 1 You can use similar syntax to define a function. Just provide additional parameters for the arguments. # let add arg1 arg2 = arg1 + arg2;; val add : int -> int -> int = <fun> We can call it like this: # add 1...
[1, 2, [[3, 4], [5]], 6].flatten # => [1, 2, 3, 4, 5, 6] If you have a multi-dimensional array and you need to make it a simple (i.e. one-dimensional) array, you can use the #flatten method.
If targeting Flash Player 11+, the built-in removeChildren method is the best way to remove all children: removeChildren(); //a start and end index can be passed For legacy applications, the same can be accomplished with a loop: while (numChildren > 0) { removeChildAt(0); }
Detailed instructions on getting date set up or installed.
We define the type of boolean expressions whose atoms are identified by strings as type expr = | Atom of string | Not of expr | And of expr * expr | Or of expr * expr and can evaluate these expressions using an oracle : string -> bool giving the values of the atoms we find as follows: le...
Pattern matching allows to deconstruct complex values and it is by no way limited to the “outer most” level of the representation of a value. To illustrate this, we implement the function transforming a boolean expression into a boolean expression where all negations are only on atoms, the so calle...
The List.fold_left and List.fold_right functions are higher-order functions that implement the outer logic of list aggregation. Aggregating a list, sometimes also referred to as reducing a list, means computing a value derived from the sequential inspection of all items in that list. The documenta...
In Elm, reducing functions are called "folds", and there are two standard methods to "fold" values up: from the left, foldl, and from the right, foldr. > List.foldl (+) 0 [1,2,3] 6 : number The arguments to foldl and foldr are: reducing function: newValue -> accumul...
Woocommerce is a plugin for WordPress and can be installed like any other WordPress plugin. WooCommerce can only be installed on self hosted installations of WordPress, it cannot be installed onto a site hosted by the wordpress.com service. If you don't have WordPress installed for your website, fo...
Detailed instructions on getting monogame set up or installed.
3 You can use rem defined by the font-size of your html tag to style elements by setting their font-size to a value of rem and use em inside the element to create elements that scale with your global font-size. HTML: <input type="button" value="Button"> <input type=...

Page 73 of 269