(filter list var exp) -> list
This function iterates over an input list and evaluates the given expression (binding the given variable to each list item). The resulting list omits items for which the expression evaluates to Nil.
Example:
Code: Select all
(filter '(1 2 3) i True) -> (1 2 3)
(filter '(1 2 3) i Nil) -> Nil [empty list]
(filter '(1 2 3) i (eq i 2)) -> (2)
(filter '(1 2 3) i (leq i 2)) -> (1 2)
If 'source' is a list, then we look for an item in the list that is equal to 'target' and return the item position. Otherwise, we assume that 'source' is a string and look for the substring 'target' in 'source' and return the character position. In either case, if we do not find anything, the function returns Nil.
Example:
Code: Select all
(find '(17 20 6 31) 6) -> 2
(find '(17 20 6 31) 571) -> Nil
(find "Sphinx of black quartz" "black") -> 10
(find '("red" "green" "blue" "yellow") "green") -> 1
Return the highest number of a list of numbers.
Example:
Code: Select all
(max 4 70) -> 70
(max 10 17 81 7) -> 81
(max '(10 17 81 7)) -> 81
Same as (max) but returns the smallest number in the list.
(objGetObjByID objID) -> obj
This is the reverse of (objGetID). To recap: an objID is a not the same as an object pointer. An objID is a globally unique identifier that is valid across systems and game saves. This new function converts from an objID to an object pointer (so that you can call other functions).
If the object is not in the current system or has been destroyed, (objGetObjByID) returns Nil.
(objGetID) is somewhat expensive (it does a linear search of all objects in the system).
(shuffle list) -> list
This function randomly shuffles the elements in the input list.
Example:
Code: Select all
(shuffle '(1 2 3 4 5 6 7)) -> (2 5 6 1 3 4 7)
(shuffle '(1 2 3 4 5 6 7)) -> (3 6 5 4 7 1 2)
(shuffle '(1 2 3 4 5 6 7)) -> (4 1 5 7 2 6 3)