[ exp exp ... ]
( list index )
-> (set r [ 1 2 3 ]) [ 1 2 3 ] -> (r 0) 1 -> (r 3) * Index 3 out of range. Null -> (set s [['x' 7] ['q' 100] [42.0 "obsequious"]] ) [ [ 'x' 7 ] [ 'q' 100 ] [ 42.0 "obsequious" ] ] -> ((s 2) 1) "obsequious"
-> (set alist [ 3 4 5 6 ]) [ 3 4 5 6 ] -> (length alist) 4 -> (head alist) 3 -> (tail alist) 6 -> (set blist "Corporal Clegg") "Corporal Clegg" -> (length blist) 14 -> (tail blist) 'g'
append accepts any number of lists and concatenates them together to form one big list.-> (set x [0 1 2 3]) [ 0 1 2 3 ] -> (insert-before 1 42 x) [ 0 42 1 2 3 ] -> (insert-after 2 42 x) [ 0 1 2 42 3 ] -> (head-insert 42 x) [ 42 0 1 2 3 ] -> (tail-insert 42 x) [ 0 1 2 3 42 ]
-> (append [1 2 3] [4 5 6] [7 8 9]) [ 1 2 3 4 5 6 7 8 9 ] -> (append "gold" "finger") "goldfinger"
-> (set x [0 1 2 3 4 5 6 7 8 9]) [ 0 1 2 3 4 5 6 7 8 9 ] -> (sublist 3 8 x) [ 3 4 5 6 7 8 ] -> (first 3 x) [ 0 1 2 ] -> (last 4 x) [ 6 7 8 9 ] -> (allbutfirst 1 x) [ 1 2 3 4 5 6 7 8 9 ] -> (allbutlast 1 x) [ 0 1 2 3 4 5 6 7 8 ]
-> (set x [ 5 4 3 2 1 ]) [ 5 4 3 2 1 ] -> (set x (change-item 3 42 x)) [ 5 4 3 42 1 ] -> (set x (change-item 5 1000 x)) [ 5 4 3 42 1 1000 ] -> (set x (remove-item 4 x)) [ 5 4 3 42 1000 ] -> (change-item 5 '!' "horse.") "horse!" -> (remove-item 1 "bleach!") "beach!" -> (change-items [0 3 6] "Wda" "Vile Message") "Wild Massage"
map is a powerful operator that applies a procedure to corresponding items in any number of argument lists, and returns a list of the results. The number of arguments the procedure accepts must match the number of argument lists passed.-> (+ 1 2 3) 6 -> (apply + [1 2 3]) 6
-> (map (proc (x) (+ 3 x)) [ 1 2 3 4 5 ]) [ 4 5 6 7 8 ] -> (map pow [ 2 3 4 5 6 ] [ 6 5 4 3 2 ]) [ 64.0 243.0 256.0 125.0 36.0 ]
-> (set alist [9 3 5 1 2 8 6 7 0 4]) [ 9 3 5 1 2 8 6 7 0 4 ] -> (sort > alist) [ 9 8 7 6 5 4 3 2 1 0 ] -> (sort < alist) [ 0 1 2 3 4 5 6 7 8 9 ] -> (foremost < alist) 8 -> (hindmost < alist) 0 -> (reorder [3 1 2 7 0] alist) [ 1 3 5 7 9 ]
make-series creates a list that starts with start, contains len number of items, where each sucessive item is increment greater than the last.-> (reverse [1 2 3 4 5]) [ 5 4 3 2 1 ] -> (reverse "redrum") "murder" -> (make-list 10 42) [ 42 42 42 42 42 42 42 42 42 42 ] -> (make-list 5 Null) [ Null Null Null Null Null ] -> (make-list 42 'a') "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
assoc searches a list of lists for a particular item. If the given key matches the first item of one of the lists, the entire matching list is returned. Otherwise, Null is returned. As such, assoc can be useful in searching a database that takes the form of a list of lists.-> (make-series 0 10 1) [ 0 1 2 3 4 5 6 7 8 9 ] -> (make-series 1 5 10) [ 1 11 21 31 41 ] -> (make-series 0 10 -3) [ 0 -3 -6 -9 -12 -15 -18 -21 -24 -27 ] -> (make-series 'A' 26 1) "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-> (set database [ ["stefan" "E15-348"] ["jacky" "E15-351"] ["wad" "E15-355"] ]) [ [ "stefan" "E15-348" ] [ "jacky" "E15-351" ] [ "wad" "E15-355" ] ] -> (assoc "stefan" database) [ "stefan" "E15-348" ] -> (assoc "wad" database) [ "wad" "E15-355" ] -> (assoc "prince" database) Null
-> (toupper 'a') 'A' -> (tolower 'M') 'm' -> (toupper 'R') 'R' -> (toupper 45) 45 -> (upcase "louder") "LOUDER" -> (downcase "SOFTER") "softer" -> (upcase [ "brazil" "uganda" "chile" ]) [ "BRAZIL" "UGANDA" "CHILE" ] -> (upcase [ 3 2 1 "ignition" ]) [ 3 2 1 "IGNITION" ]
-> (print "Stefan" tab tab "E15-348" tab tab dquote "agent 42" dquote newline) Stefan E15-348 "agent 42"
search-all looks for all occurrences of a value in a list and returns a list of indices. remove-all removes all occurrences of a value from a list and returns the modified list. replace-all replaces all occurrences of a value and returns the modified list.
search-list looks for a list l1 embedded in another list l2 and returns the starting index of the first occurrence or Null if not found. Since strings are just lists of characters, search-string points to the same function as search-list and has the same effect.
remove-list and remove-string also point to the same function, as do replace-list and replace-string. The former function removes all occurrences of a list l1 embedded in another list l2 and return the modified list. The latter replaces all occurrences of an embedded list with a new list and returns the modified list.
-> (search 42 [ 40 75 42 64 42 42 30 ]) 2 -> (remove 42 [ 40 75 42 64 42 42 30 ]) [ 40 75 64 42 42 30 ] -> (remove-all 42 [ 40 75 42 64 42 42 30 ]) [ 40 75 64 30 ] -> (replace-all 42 "zap" [ 40 75 42 64 42 42 30 ]) [ 40 75 "zap" 64 "zap" "zap" 30 ] -> (search 'a' "manual labor") 1 -> (search-all 'a' "manual labor") [ 1 4 8 ] -> (search-all 'e' "manual labor") [] -> (replace-all 'e' 'a' "bed gremmer") "bad grammar" -> (remove-all 'q' "qsqeqcqrqeqtq qmqeqsqsqaqgqeq") "secret message" -> (search-list [42 42] [ 40 75 42 64 42 42 30 ]) 4 -> (search-string "brown" "the big brown bear") 8 -> (search-string "shaft" "the big brown bear") Null -> (replace-string "bear" "beaver" "the big brown bear") "the big brown beaver" -> (remove-string "brown" "the big brown bear") "the big bear"
string-to-word-list separates a string to a list of words with no spaces.
string-to-line-list separates a string to a list of lines, where each line is of a length less than maxlinelength. The only exception is if there is a word in the string which is itself longer than maxlinelength; in this case the word is given its own line and is not truncated. Any existing newline characters are NOT given special treatment and do not force a line break.-> (string-to-word-list "Bob Jones was very sure of the color.") [ "Bob" "Jones" "was" "very" "sure" "of" "the" "color." ] -> (string-to-word-list "Yes, I am!") [ "Yes," "I" "am!" ]
fill-text fills a piece of text, adding newline characters to keep lines at a maximum length. If a word is too long for the line, it is not broken. It leaves any newlines already in the text untouched.-> (string-to-line-list 20 "Bob, please do not speak out of turn.") [ "Bob, please do not" "speak out of turn." ] -> (string-to-line-list 5 "But I was only trying to be a good boy.") [ "But I" "was" "only" "trying" "to be" "a" "good" "boy." ]
-> (fill-text 20 "this is a test of the emergency broadcast system.") "this is a test of the emergency broadcast system." -> (fill-text 10 "this is a test of the emergency broadcast system.") "this is a test of the emergency broadcast system."
Scripts: | (load "list-utilities.isis")
|