Tutorial by Examples: is

Any symbol in Common Lisp has a slot for a variable to be bound and a separate slot for a function to be bound. Note that the naming in this example is only for illustration. Global variables should not be named foo, but *foo*. The latter notation is a convention to make it clear that the variable ...
let list1 = [ 1; 2 ] let list2 = [ 1 .. 100 ] // Accessing an element printfn "%A" list1.[0] // Pattern matching let rec patternMatch aList = match aList with | [] -> printfn "This is an empty list" | head::tail -> printfn "This list consists o...
Create a .gitattributes file in the project root containing: * -text This is equivalent to setting core.autocrlf = false.
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,...
Keyword lists are lists where each item in the list is a tuple of an atom followed by a value. keyword_list = [{:a, 123}, {:b, 456}, {:c, 789}] A shorthand notation for writing keyword lists is as follows: keyword_list = [a: 123, b: 456, c: 789] Keyword lists are useful for creating ordered ...
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...
map is a function in functional programming which given a list and a function, returns a new list with the function applied to each item in that list. In Elixir, the map/2 function is in the Enum module. iex> Enum.map([1, 2, 3, 4], fn(x) -> x + 1 end) [2, 3, 4, 5] Using the alternative c...
JavaScript has four different equality comparison operations. SameValue It returns true if both operands belong to the same Type and are the same value. Note: the value of an object is a reference. You can use this comparison algorithm via Object.is (ECMAScript 6). Examples: Object.is(1, 1); ...
The notation 'thing is equal to (quote thing). The reader will do the expansion: > (read-from-string "'a") (QUOTE A) Quoting is used to prevent further evaluation. The quoted object evaluates to itself. > 'a A > (eval '+ 1 2) 3
docker exec -it <container id> /bin/bash It is common to log in an already running container to make some quick tests or see what the application is doing. Often it denotes bad container use practices due to logs and changed files should be placed in volumes. This example allows us log in the...
// Using Visual Format Language requires a special look-up dictionary of names<->views. var views = new NSDictionary( nameof(someLabel), someLabel, nameof(anotherLabel), anotherLabel, nameof(oneMoreLabel), oneMoreLabel ); // It can also take a look-up dictionary for metrics (...
A simple way of selecting between functions at compile time is to dispatch a function to an overloaded pair of functions that take a tag as one (usually the last) argument. For example, to implement std::advance(), we can dispatch on the iterator category: namespace details { template <clas...
Python makes it very simple to check whether an item is in a list. Simply use the in operator. lst = ['test', 'twest', 'tweast', 'treast'] 'test' in lst # Out: True 'toast' in lst # Out: False Note: the in operator on sets is asymptotically faster than on lists. If you need to use it ...
When working on a project, you might be half-way through a feature branch change when a bug is raised against master. You're not ready to commit your code, but you also don't want to lose your changes. This is where git stash comes in handy. Run git status on a branch to show your uncommitted chang...
Big-O notation is a notation used to talk about the long-term growth rates of functions. It's often used in the analysis of algorithms to talk about the runtime of an algorithm or related concepts like space complexity. In common usage, big-O notation is used to talk about how an algorithm's runtim...
Floating point numbers of type real cannot have any real value. They can represent real numbers up to certain amount of decimal digits. FORTRAN 77 guaranteed two floating point types and more recent standards guarantee at least two real types. Real variables may be declared as real x double prec...
With this example, we will see how to load a color image from disk and display it using OpenCV's built-in functions. We can use the C/C++, Python or Java bindings to accomplish this. In C++: #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> #include <iostream> usi...
One can iterate over a list using ~{ and ~} directives. CL-USER> (format t "~{~a, ~}~%" '(1 2 3 4 5)) 1, 2, 3, 4, 5, ~^ can be used to escape if there are no more elements left. CL-USER> (format t "~{~a~^, ~}~%" '(1 2 3 4 5)) 1, 2, 3, 4, 5 A numeric argument can ...
Ruby extends the standard group syntax (...) with a named group, (?<name>...). This allows for extraction by name instead of having to count how many groups you have. name_reg = /h(i|ello), my name is (?<name>.*)/i #i means case insensitive name_input = "Hi, my name is Zaphod Be...
You can use the reversed function which returns an iterator to the reversed list: In [3]: rev = reversed(numbers) In [4]: rev Out[4]: [9, 8, 7, 6, 5, 4, 3, 2, 1] Note that the list "numbers" remains unchanged by this operation, and remains in the same order it was originally. To r...

Page 13 of 109