Tutorial by Examples: al

The Java Collections Framework provides two related methods for all Collection objects: size() returns the number of entries in a Collection, and isEmpty() method returns true if (and only if) the Collection is empty. Both methods can be used to test for collection emptiness. For example: C...
In order to convert any callback API to promises assuming the promisify and promisifyAll version doesn't fit - you can use the promise constructor. Creating promises generally means specifying when they settle - that means when they move to the fulfilled (completed) or rejected (errored) phase to i...
#include <stdio.h> #include <math.h> #include <omp.h> #define N 1000000 int main() { double sum = 0; double tbegin = omp_get_wtime(); #pragma omp parallel for reduction( +: sum ) for ( int i = 0; i < N; i++ ) { sum += cos( i ); } ...
realloc is conceptually equivalent to malloc + memcpy + free on the other pointer. If the size of the space requested is zero, the behavior of realloc is implementation-defined. This is similar for all memory allocation functions that receive a size parameter of value 0. Such functions may in fact ...
Member functions can also be declared virtual. In this case, if called on a pointer or reference to an instance, they will not be accessed directly; rather, they will look up the function in the virtual function table (a list of pointers-to-member-functions for virtual functions, more commonly know...
Sometimes it can be useful to test your Powershell data files and iterate through the nodes and servers. Powershell 5 (WMF5) added this neat little feature for doing this called Import-PowerShellDataFile . Example: $data = Import-PowerShellDataFile -path .\MydataFile.psd1 $data.AllNodes
Detailed instructions on getting pthreads set up or installed.
Apart from primitives, the Explicit Layout structs (Unions) in C#, can also contain other Structs. As long as a field is a Value type and not a Reference, it can be contained in a Union: using System; using System.Runtime.InteropServices; // The struct needs to be annotated as "Explici...
Sometimes a new Java programmer will write code like this: public void check(boolean ok) { if (ok == true) { // Note 'ok == true' System.out.println("It is OK"); } } An experienced programmer would spot that as being clumsy and want to rewrite it as: publ...
Local variables - Those declared within a procedure (subroutine or function) of a class (or other structure). In this example, exampleLocalVariable is a local variable declared within ExampleFunction(): Public Class ExampleClass1 Public Function ExampleFunction() As Integer Dim exa...
$ npm install -g parse-server mongodb-runner $ mongodb-runner start $ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test You can use any arbitrary string as your application id and master key. These will be used by your clients to authenticate with...
file:write_file("myfile.txt", ["Hi " [<<"there">>], $\n]).
["Guten Tag " | [<<"Hello">>]]. [<<"Guten Tag ">> | [<<"Hello">>]]. [$G, $u, $t, $e, $n , $T, $a, $g | [<<"Hello">>]]. [71,117,116,101,110,84,97,103,<<"Hello">>].
Data_1 = [<<"Hello">>]. Data_2 = [Data_1,<<" Guten Tag ">>].
The following example uses allow and receive to stub a Cart's call to a CreditCardService so that the example doesn't have to wait for a network call or use a credit card number that the processor knows about. class Cart def check_out begin transaction_id = CreditCardService.instance...
CLISP has an integration with GNU Readline. For improvements for other implementations see: How to customize the SBCL REPL.
Most Common Lisp implementations will try to load an init file on startup: ImplementationInit fileSite/System Init fileABCL$HOME/.abclrcAllegro CL$HOME/.clinit.clECL$HOME/.eclrcClasp$HOME/.clasprcCLISP$HOME/.clisprc.lispClozure CLhome:ccl-init.lisp or home:ccl-init.fasl or home:.ccl-init.lispCMUCL$...
Some programmers think that it is a good idea to save space by using a null to represent an empty array or collection. While it is true that you can save a small amount of space, the flipside is that it makes your code more complicated, and more fragile. Compare these two versions of a method for ...
On StackOverflow, we often see code like this in Answers: public String joinStrings(String a, String b) { if (a == null) { a = ""; } if (b == null) { b = ""; } return a + ": " + b; } Often, this is accompanied with an asse...
Rust's coherence rule requires that either the trait or the type for which you are implementing the trait must be defined in the same crate as the impl, so it is not possible to implement Serialize and Deserialize for a type in a different crate directly. The newtype pattern and Deref coercion provi...

Page 155 of 269