Tutorial by Examples: c

(loop for s being the symbols in 'cl do (print s)) (loop for s being the present-symbols in :cl do (print s)) (loop for s being the external-symbols in (find-package "COMMON LISP") do (print s)) (loop for s being each external-symbols of "COMMON LISP" ...
(loop for i from 0 to 10 do (print i)) ; prints 0 1 2 3 4 5 6 7 8 9 10 (loop for i from 0 below 10 do (print i)) ; prints 0 1 2 3 4 5 6 7 8 9 10 (loop for i from 10 above 0 do (print i)) ; prints 10 9 8 7 6 5 4 3 2 1 (loop for i from 10 to 0 do (print i)) ; prints noth...
Combining typedef with struct can make code clearer. For example: typedef struct { int x, y; } Point; as opposed to: struct Point { int x, y; }; could be declared as: Point point; instead of: struct Point point; Even better is to use the following typedef struct Poin...
The emptiness of a list is associated to the boolean False, so you don't have to check len(lst) == 0, but just lst or not lst lst = [] if not lst: print("list is empty") # Output: list is empty
This example assumes you have already installed Java and Gradle. Use the following project structure: src/ main/ java/ com/ example/ Application.java build.gradle build.gradle is your build script for Gradle build system with the following content: buildscri...
You should implement SFSafariViewControllerDelegate so that your class is notified when the user hits the Done button on the SafariViewController and you can dismiss it as well. First declare your class to implement the protocol. class MyClass: SFSafariViewControllerDelegate { } Implement th...
Don't forget to import the necessary framework first. import SafariServices //Objective-C @import SafariServices; Instantiate a SafariViewController instance. let safariVC = SFSafariViewController(URL: URL(string: "your_url")!) //Objective-C @import SafariServices; NSURL *URL = [...
The function map() from the package maps provides a simple starting point for creating maps with R. A basic world map can be drawn as follows: require(maps) map() The color of the outline can be changed by setting the color parameter, col, to either the character name or hex value of a color...
Considering the following dictionary: d = {"a": 1, "b": 2, "c": 3} To iterate through its keys, you can use: for key in d: print(key) Output: "a" "b" "c" This is equivalent to: for key in d.keys(): print(key) ...
Run the command below in a shell after installing Ruby. This shows how you can execute simple Ruby programs without creating a Ruby file: ruby -e 'puts "Hello World"' You can also feed a Ruby program to the interpreter's standard input. One way to do that is to use a here document in...
Say you have a library website, and you want to have a custom post type named Books. It can be registered as function create_bookposttype() { $args = array( 'public' => true, 'labels' => array( 'name' => __( 'Books' ), 'singular_name' => ...
Slices are objects in themselves and can be stored in variables with the built-in slice() function. Slice variables can be used to make your code more readable and to promote reuse. >>> programmer_1 = [ 1956, 'Guido', 'van Rossum', 'Python', 'Netherlands'] >>> programmer_2 = [ 18...
A factory decreases coupling between code that needs to create objects from object creation code. Object creation is not made explicitly by calling a class constructor but by calling some function that creates the object on behalf the caller. A simple Java example is the following one: interface Ca...
using System.Text; using System.IO; string filename = "c:\path\to\file.txt"; //'using' structure allows for proper disposal of stream. using (StreamWriter writer = new StreamWriter(filename")) { writer.WriteLine("Text to Write\n"); }
using System.IO; using System.Text; string filename = "c:\path\to\file.txt"; File.writeAllText(filename, "Text to write\n");
A basic plot is created by calling plot(). Here we use the built-in cars data frame that contains the speed of cars and the distances taken to stop in the 1920s. (To find out more about the dataset, use help(cars)). plot(x = cars$speed, y = cars$dist, pch = 1, col = 1, main = "Distance ...
To split one component off of the path: >>> p = os.path.join(os.getcwd(), 'foo.txt') >>> p '/Users/csaftoiu/tmp/foo.txt' >>> os.path.dirname(p) '/Users/csaftoiu/tmp' >>> os.path.basename(p) 'foo.txt' >>> os.path.split(os.getcwd()) ('/Users/csafto...
Every package requires a setup.py file which describes the package. Consider the following directory structure for a simple package: +-- package_name | | | +-- __init__.py | +-- setup.py The __init__.py contains only the line def foo(): return 100. The following setup.py...
docopt turns command-line argument parsing on its head. Instead of parsing the arguments, you just write the usage string for your program, and docopt parses the usage string and uses it to extract the command line arguments. """ Usage: script_name.py [-a] [-b] <path> ...
Comparing sets In R, a vector may contain duplicated elements: v = "A" w = c("A", "A") However, a set contains only one copy of each element. R treats a vector like a set by taking only its distinct elements, so the two vectors above are regarded as the same: set...

Page 104 of 826