Tutorial by Examples: c

(let [x true y true z true] (match [x y z] [_ false true] 1 [false true _ ] 2 [_ _ false] 3 [_ _ true] 4)) ;=> 4
(let [v [1 2 3]] (match [v] [[1 1 1]] :a0 [[1 _ 1]] :a1 [[1 2 _]] :a2)) ;; _ is used for wildcard matching ;=> :a2
(let [x {:a 1 :b 1}] (match [x] [{:a _ :b 2}] :a0 [{:a 1 :b _}] :a1 [{:x 3 :y _ :z 4}] :a2)) ;=> :a1
(match [['asymbol]] [['asymbol]] :success) ;=> :success
One can extract a series of consecutive elements from an Array using a Range. let words = ["Hey", "Hello", "Bonjour", "Welcome", "Hi", "Hola"] let range = 2...4 let slice = words[range] // ["Bonjour", "Welcome", &quot...
C++11 NOTE: std::auto_ptr has been deprecated in C++11 and will be removed in C++17. You should only use this if you are forced to use C++03 or earlier and are willing to be careful. It is recommended to move to unique_ptr in combination with std::move to replace std::auto_ptr behavior. Before we ...
Let's say we wish to write Euclid's gcd() as a lambda. As a function, it is: int gcd(int a, int b) { return b == 0 ? a : gcd(b, a%b); } But a lambda cannot be recursive, it has no way to invoke itself. A lambda has no name and using this within the body of a lambda refers to a captured thi...
int a = 5; // 0101b (0x05) int b = 9; // 1001b (0x09) int c = a ^ b; // 1100b (0x0C) std::cout << "a = " << a << ", b = " << b << ", c = " << c << std::endl; Output a = 5, b = 9, c = 12 Why A bit wise XOR (...
unsigned char a = 234; // 1110 1010b (0xEA) unsigned char b = ~a; // 0001 0101b (0x15) std::cout << "a = " << static_cast<int>(a) << ", b = " << static_cast<int>(b) << std::endl; Output a = 234, b = 21 Why A b...
Introduction The GNU Make (styled make) is a program dedicated to the automation of executing shell commands. GNU Make is one specific program that falls under the Make family. Make remains popular among Unix-like and POSIX-like operating systems, including those derived from the Linux kernel, Mac ...
The Windows API is provided by means of a C-callable interface. Success or failure of an API call is reported strictly through return values. Exceptions aren't part of the documented contract (although some API implementations can raise SEH exceptions, e.g. when passing a read-only lpCommandLine arg...
Some API calls can succeed or fail in more than one way. The APIs commonly return additional information for both successful invocations as well as errors (e.g. CreateMutex). if ( CreateMutexW( NULL, TRUE, L"Global\\MyNamedMutex" ) == NULL ) { // Failure: get additional information. ...
When implementing SFINAE using std::enable_if, it is often useful to have access to helper templates that determines if a given type T matches a set of criteria. To help us with that, the standard already provides two types analog to true and false which are std::true_type and std::false_type. The...
Add the following code (known as the "JavaScript tracking snippet") to your site's templates. The code should be added before the closing tag, and the string 'UA-XXXXX-Y' should be replaced with the property ID (also called the "tracking ID") of the Google Analytics property yo...
CSS body { counter-reset: item-counter; } .item { counter-increment: item-counter; } .item:before { content: counter(item-counter, upper-roman) ". "; /* by specifying the upper-roman as style the output would be in roman numbers */ } HTML <div class='item'>Item...
CSS body { counter-reset: item-counter; /* create the counter */ } .item { counter-increment: item-counter; /* increment the counter every time an element with class "item" is encountered */ } .item-header:before { content: counter(item-counter) ". "; /* print the v...
In Drupal 7 and lower, your configuration is probably stored using the Features module. To update a feature with changes from the databases use this command: drush features-update [feature-name] // e.g. drush features-update content_type_news You can also use this shorthand: drush fu [feature-n...
function createNewFolderInGoogleDrive(folderName) { return DriveApp.createFolder(folderName); } Use function createNewFolderInGoogleDrive to create folder named Test folder in a Google Drive root: var newFolder = createNewFolderInGoogleDrive('Test folder'); newFolder has Class Folder typ...
Use 403 Forbidden when a client has requested a resource that is inaccessible due to existing access controls. For example, if your app has an /admin route that should only be accessible to users with administrative rights, you can use 403 when a normal user requests the page. GET /admin HTTP/1.1 ...
Iterable can be anything for which items are received one by one, forward only. Built-in Python collections are iterable: [1, 2, 3] # list, iterate over items (1, 2, 3) # tuple {1, 2, 3} # set {1: 2, 3: 4} # dict, iterate over keys Generators return iterables: def foo(): # foo ...

Page 199 of 826