List operations
Head({list})
Head({list}) :
Returns the first element of the list "{list}". Example:
"Head({a,b,c});" should return "a;".
Nth({list},index)
Nth({list},index) : Returns the element in the list "{list}" at
position "index", where the first element is 1.
Tail({list})
Tail({list}) : Returns the list "{list}" without the first element.
DestructiveReverse({list})
DestructiveReverse({list}) : Returns the list {list} in reverse order.
The list is reversed in place, so the original is changed into nonsense.
Use FlatCopy to avoid this.
Length({list})
Length({list}) : Returns the length of the list {list}.
List(...)
List(...) : Returns a list with ... as its elements, after they
were evaluated. This is the same as entering "{...};".
UnList({list})
UnList({list}) :
Changes the list {list} into an expression specified in the
elements of the list. This means the first element
is treated as the command, and the elements following
are the arguments to that command. "{list}" is evaluated
before the operation is performed. Example: "UnList({Cos,x});"
would evaluate to "Cos(x);".
Listify(expression)
Listify(expression) :
Inverse of UnList: it converts the expression "expression"
into a list. Eg. "Listify(a(b));" evaluates to "{a,b};".
Concat(...)
Concat(...) : concatenates the lists in ... after evaluation.
Eg. "Concat({a,b},{c,d});" returns "{a,b,c,d};".
Delete({list},index)
Delete({list},index) :
Deletes an element at position "index" from the
list "{list}", and returns that list. "{list}" and
"index" are evaluated first. The first index in list is 1.
Insert({list},index,element)
Evaluates arguments, and inserts "element"
in "{list}" at position "index", where position
1 means insert at the front of the existing list. The result is returned,
and the original list is left unchanged.
DestructiveInsert({list},index,element)
DestructiveInsert({list},index,element) :
The Destructive... versions actually perform the operations
on the original lists. So, if
a variable is bound to a list, the list the variable points
to is actually modified. This is more efficient memory-wise
and in execution if the same variable is going to be set to
the result.
DestructiveDelete({list},index)
DestructiveDelete({list},index) :
The Destructive... versions actually perform the operations
on the original lists. So, if
a variable is bound to a list, the list the variable points
to is actually modified. This is more efficient memory-wise
and in execution if the same variable is going to be set to
the result.
Replace({list},index,element)
This replaces an element, much like calling Delete and Insert
in sequence.
DestructiveReplace({list},index,element)
This replaces an element, much like calling DestructiveDelete
and DestructiveInsert in sequence.
FlatCopy({list})
FlatCopy({list}) :
Copying of the contents of a list. It is not recursed
into, only the first level is copied. This is useful
in combination with the destructive commands that actually
modify lists in place (for efficiency).
Contains({list},element)
Contains({list},element) :
Returns whether "{list}" contains element "element".
Find(list,item)
Find(list,item) : returns the index of item in the list.
Example: Find({a,b,c,d},c) returns 3.
Append({list},element)
Append({list},element) :
Append an element {{I:element}} to list {{I:{list} }}.
DestructiveAppend({list},element)
DestructiveAppend({list},element) :
Append an element {{I:element}} to list {{I:{list} }}.
RemoveDuplicates({list})
RemoveDuplicates({list}) :
Returns a list with exactly one occurrence of each element that is
also in "{list}".
Push(stack,element)
These implement a stack (represented as a list). "Push" adds an element
in front of the list. "Pop" then removes and returns any element you
need from the list. "PopFront" and "PopBack" pop the first and last
element of the stack respectively.
Pop(stack,index)
These implement a stack (represented as a list). "Push" adds an element
in front of the list. "Pop" then removes and returns any element you
need from the list. "PopFront" and "PopBack" pop the first and last
element of the stack respectively.
PopFront(stack)
These implement a stack (represented as a list). "Push" adds an element
in front of the list. "Pop" then removes and returns any element you
need from the list. "PopFront" and "PopBack" pop the first and last
element of the stack respectively.
PopBack(stack)
These implement a stack (represented as a list). "Push" adds an element
in front of the list. "Pop" then removes and returns any element you
need from the list. "PopFront" and "PopBack" pop the first and last
element of the stack respectively.
Swap({list},i1,i2)
Swap({list},i1,i2) :
Swap elements with indices "i1" and "i2" in the list "{list}".
Count({list},element)
Count({list},element) :
Returns number of occurrences of "element" in "{list}".
Intersection({list1},{list2})
Intersection({list1},{list2}) :
returns the intersection of two lists.
Example : "Intersection({a,b},{b,c});" would evaluate to "{b};".
Union({list1},{list2})
Union({list1},{list2}) :
returns the union of two lists.
Example : "Union({a,b},{b,c});" would evaluate to "{a,b,b};".
Difference({list1},{list2})
Difference({list1},{list2}) :
returns the difference of two lists.
FillList(aItem, aLength)
FillList(aItem, aLength) : create a list with length aLength,
filling it with aItem.
Example: "FillList(0,5)" returns {0,0,0,0,0}
Drop(list,which)
Drop( list, n ) gives 'list' with its first n elements dropped
Drop( list, -n ) gives 'list' with its last n elements dropped
Drop( list, {m,n} ) gives 'list' with elements m through n dropped
Take(list,which)
Take( list, n ) gives the first n elements of 'list'
Take( list, -n ) gives the last n elements of 'list'
Take( list, {m,n} ) elements m through n of 'list'
Partition( list, n )
Partition( list, n ) partitions 'list' into non-overlapping sublists of length n
Assoc(key,assoclist)
Treat assoclist as a traditional assoc list well known from Lisp, and return
the element stored with key. This functionality is probably best
accessed through the [[ ]] operator.
AssocIndices(list)
Return the list of keys in the associated list assoclist.