Tutorial by Examples

Prolog tries alternative clauses for a predicate in the order of appearance: likes(alice, music). likes(bob, hiking). // Either alice likes music, or bob likes hiking will succeed. The disjunction (OR) operator ; can be used to express this in one rule: likes(P,Q) :- ( P = alice , Q = ...
Conjunction (logical AND) is represented by the comma , operator (among other roles). Conjunction between clauses can appear in a query: ?- X = 1, Y = 2. Conjunction can also appear between the subgoal clauses in the body of a rule: triangleSides(X,Y,Z) :- X + Y > Z, X + Z > Y, Y + ...
Sometimes it is desirable to prevent Prolog from backtracking into alternative solutions. The basic tool available to the programmer to stop prolog from continuing futher in its backtrack is the cut operator. consider the following. % (percent signs mean comments) % a is the parent of b, c, and d....
ValueAnimator introduces a simple way to animate a value (of a particular type, e.g. int, float, etc.). The usual way of using it is: Create a ValueAnimator that will animate a value from min to max Add an UpdateListener in which you will use the calculated animated value (which you can obtain ...
ObjectAnimator is a subclass of ValueAnimator with the added ability to set the calculated value to the property of a target View. Just like in the ValueAnimator, there are two ways you can create the ObjectAnimator: (the example code animates an alpha of a View from 0.4f to 0.2f in 250ms) Fr...
ViewPropertyAnimator is a simplified and optimized way to animate properties of a View. Every single View has a ViewPropertyAnimator object available through the animate() method. You can use that to animate multiple properties at once with a simple call. Every single method of a ViewPropertyAnimat...
Official page: https://www.rebar3.org/ Source code: https://github.com/erlang/rebar3 Rebar3 is mainly a dependency manager for Erlang and Elixir projects, but it also offers several other features, like bootstrapping projects (according to several templates, following the OTP principles), task exe...
Rebar3 is written in Erlang, so you need Erlang to run it. It is available as a binary that you can download and run. Just fetch the nightly build and give it execution permissions: $ wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3 Place this binary in a convenient place a...
As Rebar3 is free, open source and written in Erlang, it's possible to simply clone and build it from the source code. $ git clone https://github.com/erlang/rebar3.git $ cd rebar3 $ ./bootstrap This will create the rebar3 script, which you can put on your PATH or link to /usr/local/bin as expl...
To bootstrap a new Erlang project, simply choose the template you want to use from the list. The available templates can be retrieved by the following command: $ rebar3 new app (built-in): Complete OTP Application structure cmake (built-in): Standalone Makefile for building C/C++ in c_src escr...
We can always use ListView or RecyclerView for selection from list of items, but if we have small amount of choices and among those choices we want user to select one, we can use AlertDialog.Builder setAdapter. private void showDialog() { AlertDialog.Builder builder = new AlertDia...
Sectioning is a concise way to partially apply arguments to infix operators. For example, if we want to write a function which adds "ing" to the end of a word we can use a section to succinctly define a function. > (++ "ing") "laugh" "laughing" Notice...
Hash tables are created by make-hash-table: (defvar *my-table* (make-hash-table)) The function may take keyword parameters to further specify the behavior of the resulting hash table: test: Selects the function used to compare keys for equality. Maybe a designator for one of the functions eq,...
(defun print-entry (key value) (format t "~A => ~A~%" key value)) (maphash #'print-entry *my-table*) ;; => NIL Using maphash allows to iterate over the entries of a hash table. The order of iteration is unspecified. The first argument is a function accepting two parameters: ...
Extractor behavior can be used to derive arbitrary values from their input. This can be useful in scenarios where you want to be able to act on the results of a transformation in the event that the transformation is successful. Consider as an example the various user name formats usable in a Window...
Map 'Mapping' across a collection uses the map function to transform each element of that collection in a similar way. The general syntax is: val someFunction: (A) => (B) = ??? collection.map(someFunction) You can provide an anonymous function: collection.map((x: T) => /*Do something wi...
Single slots are used when a child component only defines one slot within its template. The page component above uses a single slot to distribute content. An example of the page component's template using a single slot is below: <html> <head> <title>Page Title</t...
Slots offer a convenient way of distributing content from a parent component to a child component. This content can be anything from text, HTML or even other components. It can be helpful sometimes to think of slots as a means of injecting content directly into a child component's template. Slots ...
Named slots work similarly to single slots but instead allow you to distribute content to different regions within your child component template. Take the page component from the previous example but modify it's template so it is as follows: <html> <head> <title>Pag...
The variable command ensures that a given namespace variable is created. Until a value is assigned to it, the variable's value is undefined: namespace eval mynamespace { variable alpha set alpha 0 } The variable can be accessed from outside the namespace (from anywhere, in fact) by at...

Page 605 of 1336