(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"
...
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...
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)
...
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...
Dim filename As String = "c:\path\to\file.txt"
If System.IO.File.Exists(filename) Then
Dim writer As New System.IO.StreamWriter(filename)
writer.Write("Text to write" & vbCrLf) 'Add a newline
writer.close()
End If
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...
The %in% operator compares a vector with a set.
v = "A"
w = c("A", "A")
w %in% v
# TRUE TRUE
v %in% w
# TRUE
Each element on the left is treated individually and tested for membership in the set associated with the vector on the right (consisting of all its...
To find every vector of the form (x, y) where x is drawn from vector X and y from Y, we use expand.grid:
X = c(1, 1, 2)
Y = c(4, 5)
expand.grid(X, Y)
# Var1 Var2
# 1 1 4
# 2 1 4
# 3 2 4
# 4 1 5
# 5 1 5
# 6 2 5
The result is a data.frame with one...
unique drops duplicates so that each element in the result is unique (only appears once):
x = c(2, 1, 1, 2, 1)
unique(x)
# 2 1
Values are returned in the order they first appeared.
duplicated tags each duplicated element:
duplicated(x)
# FALSE FALSE TRUE TRUE TRUE
anyDuplicated(x) >...
To count how many elements of two sets overlap, one could write a custom function:
xtab_set <- function(A, B){
both <- union(A, B)
inA <- both %in% A
inB <- both %in% B
return(table(inA, inB))
}
A = 1:20
B = 10:30
xtab_set(A, B)
# inB
...
Sets are unordered collections of distinct elements. But sometimes we want to work with unordered collections of elements that are not necessarily distinct and keep track of the elements' multiplicities.
Consider this example:
>>> setA = {'a','b','b','c'}
>>> setA
set(['a', 'c'...
A vector is denoted by square brackets:
[]
;;=> []
[:foo]
;;=> [:foo]
[:foo :bar]
;;=> [:foo :bar]
[1 (+ 1 1) 3]
;;=> [1 2 3]
In addition using to the literal syntax, you can also use the vector function to construct a vector:
(vector)
;;=> []
(vector :foo)
;;=&...
The boolean type cannot be cast to/from any other primitive type.
A char can be cast to/from any numeric type by using the code-point mappings specified by Unicode. A char is represented in memory as an unsigned 16-bit integer value (2 bytes), so casting to byte (1 byte) will drop 8 of those bits (...
Numeric primitives can be cast in two ways. Implicit casting happens when the source type has smaller range than the target type.
//Implicit casting
byte byteVar = 42;
short shortVar = byteVar;
int intVar = shortVar;
long longVar = intvar;
float floatVar = longVar;
double doubleVar = floatVar...
When trying to select from a table called order like this
select * from order
the error rises:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order' at line 1
Reserved keywords in MySQ...