next up previous contents index
Next: Booleans Up: List of primitives Previous: Arithmetical and logical operations   Contents   Index

Operations on lists

Primitives Arguments Use
word a b Concatenates the two words a and b. Eg: pr word "a 1 returns a1
list a b Returns a list composed of a and b. For example, list 3 6 returns [3 6]. list ``a ``list returns [a list]
sentence, se a b Returns a list composed of a and b. If a or b is a list, then each element of a and b will become an element of the resulting list (square brackets are deleted).
Eg: se [4 3] ``hello returns [4 3 hello]
se [how are] ``things returns [how are things]
fput a b: a anything, b list Insert a in the first slot in list b.
Eg : fput ``cocoa [2] returns [cocoa 2]
lput a b: a anything, b list Insert a in the last slot of list b
Eg: lput 5 [7 9 5] returns [7 9 5 5]
reverse a : list Reverse the order of elements in list a
reverse [1 2 3] returns [3 2 1]
pick a : a word or list If a is a word, returns one of the letters of a at random. If a is a list, returns one of the elements of a at random.
remove a b: a anything, b list Remove element a from list b if it occurs there.
Eg: remove 2 [1 2 3 4 2 6 ] returns [1 3 4 6]
item a b: a whole number, b list or word If b is a word, returns the letter numbered a from the word (1 represents the first letter). If b is a list, returns the element numbered a from the list.
butlast,bl a: list or word If a is a list, returns the whole list except for its last element. If a is a word, returns the word minus its last letter.
butfirst, bf a: list or word If a is a list, returns the whole list except for its first element. If a is a word, returns the word minus its first letter.
last a: list or word If a is a list, returns the last element of the list. If a is a word, returns the last letter of the word.
first a: list or word If a is a list, returns the first element of the list. If a is a word, returns the first letter of the word.
setitem, replace li1 n li2: li1 list, n integer, li2 word or list Replace the element number n in the list li, by the word or the list li2.
replace [a b c] 2 8 --> [a 8 c]
additem li1 n li2: li1 list, n integer, li2 word or list Adds at the position n in the list li the word or the list li2
additem [a b c] 2 8 --> [a 8 b c]
count a: list or word If a is a word, returns the number of letters in a. If a is a list, returns the number of elements in a.
unicode a: word returns the Unicode value of the character "a".
pr unicode "A returns 65
character, char a: number returns the character which Unicode value is "a".
pr character 65 returns "A


next up previous contents index
Next: Booleans Up: List of primitives Previous: Arithmetical and logical operations   Contents   Index
Loïc 2008-06-08