Tutorial by Examples: l

(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...
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
Assuming that bar is an alias for someCommand -flag1. Type bar on the command line and then press Ctrl+alt+e you'll get someCommand -flag1 where bar was standing.
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...
You can add items to a user's Reading List in Safari by calling the addItem method on the SSReadingList singleton. let readingList = SSReadingList.default() readingList?.addItem(with: yourURL, title: "optional title", previewText: "optional preview text") The default Reading...
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 = [...
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...
This is the code for a simple console project, that prints "Hello, World!" to STDOUT, and exits with an exit code of 0 [<EntryPoint>] let main argv = printfn "Hello, World!" 0 Example breakdown Line-by-line: [<EntryPoint>] - A .net Attribute that m...
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...
Imports System.IO Dim filename As String = "c:\path\to\file.txt" File.WriteAllText(filename, "Text to write" & vbCrLf)
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 ...
matplot is useful for quickly plotting multiple sets of observations from the same object, particularly from a matrix, on the same graph. Here is an example of a matrix containing four sets of random draws, each with a different mean. xmat <- cbind(rnorm(100, -3), rnorm(100, -1), rnorm(100, 1),...
The following program says hello to the user. It takes one positional argument, the name of the user, and can also be told the greeting. import argparse parser = argparse.ArgumentParser() parser.add_argument('name', help='name of user' ) parser.add_argument('-g', '--greeting', ...
Use os.path.abspath: >>> os.getcwd() '/Users/csaftoiu/tmp' >>> os.path.abspath('foo') '/Users/csaftoiu/tmp/foo' >>> os.path.abspath('../foo') '/Users/csaftoiu/foo' >>> os.path.abspath('/foo') '/foo'
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...
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> ...

Page 108 of 861