Tutorial by Examples

int a; std::cout << a; // Undefined behavior! This results in undefined behavior, because a is uninitialised. It is often, incorrectly, claimed that this is because the value is "indeterminate", or "whatever value was in that memory location before". However, it is th...
The call/N family of predicates can call arbitrary Prolog goals at run time: ?- G=true, call(G). true. ?- G=(true,false), call(G). false.
maplist/2 and maplist/3 are higher-order predicates, which allow the definition of a predicate to be lifted about a single element to lists of such elements. These predicates can be defined using call/2 and call/3 as building blocks and ship with many Prolog systems. For example: ?- maplist(dif(a)...
In Prolog, the so-called meta-call is a built-in language feature. All Prolog code is represented by Prolog terms, allowing goals to be constructed dynamically and be used like other goals without additional predicates: ?- Goal = dif(X, Y), Goal. dif(X, Y). Using this mechanism, other higher-or...
A fold (from the left) is a higher-order relation between: a predicate with 3 arguments a list of elements an initial state a final state, which is the result of applying the predicate to successive elements while carrying through intermediate states. For example: Use foldl/4 to express the...
In order to record audio from a user's microphone, we must first gain permission from the user to access the device: navigator.mediaDevices.getUserMedia({ audio: true }) .then(successCallback) .catch(failureCallback); On success, our successCallback will be called with a MediaStream ob...
Predicates that impede or prohibit a declarative reading of Prolog programs are extra-logical. Examples of such predicates are: !/0 (->)/2 and if-then-else (\+)/1 These predicates can only be understood procedurally, by taking into account the actual control flow of the interpreter, and a...
The keyword auto provides the auto-deduction of type of a variable. It is especially convenient when dealing with long type names: std::map< std::string, std::shared_ptr< Widget > > table; // C++98 std::map< std::string, std::shared_ptr< Widget > >::iterator i = table.fin...
Download and extract the OSGi starter kit for your platform from Equinox download page for Neon release. Start the framework from the rt/plugins folder with the following command (or your platform's rt executable from the rt folder): rt/plugins$ java -jar org.eclipse.equinox.launcher_1.3.200.v2016...
Unification is a pure relation. It does not produce side effects and can be used in all directions, with either or both arguments fully or only partially instantiated. In Prolog, unification can happen explicitly, using built-in predicates like (=)/2 or unify_with_occurs_check/2 implicitly, whe...
Optionals (also known as Maybe types) are used to represent a type whose contents may or may not be present. They are implemented in C++17 as the std::optional class. For example, an object of type std::optional<int> may contain some value of type int, or it may contain no value. Optionals ar...
BEGIN TRANSACTION INSERT INTO DeletedEmployees(EmployeeID, DateDeleted, User) (SELECT 123, GetDate(), CURRENT_USER); DELETE FROM Employees WHERE EmployeeID = 123; COMMIT TRANSACTION
local function A(name, age, hobby) print(name .. "is " .. age .. " years old and likes " .. hobby) end A("john", "eating", 23) --> prints 'john is eating years old and likes 23' -- oops, seems we got the order of the arguments wrong... -- this happ...
One of the most elementary DCG nonterminals is ... //0, which can be read as "anything at all": ... --> [] | [_], ... . It can be used to describe a list Ls that contains the element E via: phrase(( ..., [E], ... ), Ls)
DCGs can be used for parsing. Best of all, the same DCG can often be used to both parse and generate lists that are being described. For example: sentence --> article, subject, verb, object. article --> [the]. subject --> [woman] | [man]. verb --> [likes] | [enjoys]. object ...
The C-API is the most powerful way to access PostgreSQL and it is surprisingly comfortable. Compilation and linking During compilation, you have to add the PostgreSQL include directory, which can be found with pg_config --includedir, to the include path. You must link with the PostgreSQL client s...
Prerequisites In order to run Elasticsearch, a Java Runtime Environment (JRE) is required on the machine. Elasticsearch requires Java 7 or higher and recommends Oracle JDK version 1.8.0_73. Install Oracle Java 8 sudo add-apt-repository -y ppa:webupd8team/java sudo apt-get update echo "or...
The Locals window provides easy access to the current value of variables and objects within the scope of the function or subroutine you are running. It is an essential tool to debugging your code and stepping through changes in order to find issues. It also allows you to explore properties you might...
Although people often say Sass as the name of this CSS-preprocessor, they often mean the SCSS-syntax. Sass uses the .sass file extension, while SCSS-Sass uses the .scss extension. They are both referred to as "Sass". Speaking generally, the SCSS-syntax is more commonly used. SCSS looks li...
Sass tends to be the more "lazy" syntax. Nothing illustrates this nicer than how you define and include mixins. Defining a mixin = is how you define a mixin in Sass, @mixin in SCSS. // SCSS @mixin size($x: 10rem, $y: 20rem) { width: $x; height: $y; } // Sass =size($x: 10...

Page 302 of 1336