Tutorial by Examples: an

Data Manipulation Language (DML for short) includes operations such as INSERT, UPDATE and DELETE: -- Create a table HelloWorld CREATE TABLE HelloWorld ( Id INT IDENTITY, Description VARCHAR(1000) ) -- DML Operation INSERT, inserting a row into the table INSERT INTO HelloWorld (D...
do './config.pl'; This will read in the contents of the config.pl file and execute it. (See also: perldoc -f do.) N.B.: Avoid do unless golfing or something as there is no error checking. For including library modules, use require or use.
Signal numbers can be synchronous (like SIGSEGV – segmentation fault) when they are triggered by a malfunctioning of the program itself or asynchronous (like SIGINT - interactive attention) when they are initiated from outside the program, e.g by a keypress as Cntrl-C. The signal() function is part...
To conditionally include a block of code, the preprocessor has several directives (e.g #if, #ifdef, #else, #endif, etc). /* Defines a conditional `printf` macro, which only prints if `DEBUG` * has been defined */ #ifdef DEBUG #define DLOG(x) (printf(x)) #else #define DLOG(x) #endif Norm...
Swift's built-in numeric types are: Word-sized (architecture-dependent) signed Int and unsigned UInt. Fixed-size signed integers Int8, Int16, Int32, Int64, and unsigned integers UInt8, UInt16, UInt32, UInt64. Floating-point types Float32/Float, Float64/Double, and Float80 (x86-only). Literal...
func doSomething1(value: Double) { /* ... */ } func doSomething2(value: UInt) { /* ... */ } let x = 42 // x is an Int doSomething1(Double(x)) // convert x to a Double doSomething2(UInt(x)) // convert x to a UInt Integer initializers produce a runtime error if the value ove...
The searched CASE returns results when a boolean expression is TRUE. (This differs from the simple case, which can only check for equivalency with an input.) SELECT Id, ItemId, Price, CASE WHEN Price < 10 THEN 'CHEAP' WHEN Price < 20 THEN 'AFFORDABLE' ELSE 'EXPENSIVE' E...
Indexes can have several characteristics that can be set either at creation, or by altering existing indexes. CREATE CLUSTERED INDEX ix_clust_employee_id ON Employees(EmployeeId, Email); The above SQL statement creates a new clustered index on Employees. Clustered indexes are indexes that dict...
Classes are reference types, meaning that multiple variables can refer to the same instance. class Dog { var name = "" } let firstDog = Dog() firstDog.name = "Fido" let otherDog = firstDog // otherDog points to the same Dog instance otherDog.name = "Rover" // modifying otherDog also...
Classes can define properties that instances of the class can use. In this example, Dog has two properties: name and dogYearAge: class Dog { var name = "" var dogYearAge = 0 } You can access the properties with dot syntax: let dog = Dog() print(dog.name) print(dog.dogYear...
WScript.Echo "Hello world!" This displays a message on the console if run with cscript.exe (the console host) or in a message box if run with wscript.exe (the GUI host). If you're using VBScript as the server-side scripting language for a web page (for classic ASP, for example), Respo...
In MATLAB, the most basic data type is the numeric array. It can be a scalar, a 1-D vector, a 2-D matrix, or an N-D multidimensional array. % a 1-by-1 scalar value x = 1; To create a row vector, enter the elements inside brackets, separated by spaces or commas: % a 1-by-4 row vector v = [1, 2...
When creating a subscription for a user, you first need to create and activate a billing plan that a user is then subscribed to using a billing agreement. The full process for creating a subscription is detailed in the remarks of this topic. Within this example, we're going to be using the PayPal N...
When working with dictionaries, it's often necessary to access all the keys and values in the dictionary, either in a for loop, a list comprehension, or just as a plain list. Given a dictionary like: mydict = { 'a': '1', 'b': '2' } You can get a list of keys using the keys() method: ...
Optionals must be unwrapped before they can be used in most expressions. if let is an optional binding, which succeeds if the optional value was not nil: let num: Int? = 10 // or: let num: Int? = nil if let unwrappedNum = num { // num has type Int?; unwrappedNum has type Int print(&quo...
To allow the use of in for custom classes the class must either provide the magic method __contains__ or, failing that, an __iter__-method. Suppose you have a class containing a list of lists: class ListList: def __init__(self, value): self.value = value # Create a set of al...
from collections import Counter c = Counter(["a", "b", "c", "d", "a", "b", "a", "c", "d"]) c # Out: Counter({'a': 3, 'b': 2, 'c': 2, 'd': 2}) c["a"] # Out: 3 c[7] # not in the list (7 oc...
alist = [1, 2, 3, 4, 1, 2, 1, 3, 4] alist.count(1) # Out: 3 atuple = ('bear', 'weasel', 'bear', 'frog') atuple.count('bear') # Out: 2 atuple.count('fox') # Out: 0
Anonymous functions are functions that are defined but not assigned a name. The following is an anonymous function that takes in two integers and returns the sum. (x: Int, y: Int) => x + y The resultant expression can be assigned to a val: val sum = (x: Int, y: Int) => x + y Anonymous...
class MultiIndexingList: def __init__(self, value): self.value = value def __repr__(self): return repr(self.value) def __getitem__(self, item): if isinstance(item, (int, slice)): return self.__class__(self.value[item]) r...

Page 15 of 307