List

The List indicators are { and }
You can store any kind of object into list (numbers, matrix, strings, lists ....) there are no limits (except memory).

functions for lists

function usage example
size This function return the number of item that are stored into a list. { 1 2 "aaa" } gives 3
list-> Explode the list.
put into stack each item of the list and give the number. (into a list)
{ 1 2 "aaa" } gives on stack
1
2
"aaa"
{ 3 }
1, 2, and "aaa" are items, and { 3 } is the number of item
->list build a list, need the number of item to store at first information (TOS). the stack has :
"abc"
123
2
we execture ->list it gives : { "abc" 123 }
Please note that the number of item can be given in numerical 2 or in a list { 2 }.
reverse move item inside the list to perform a reversal { 1 2 "aaa" } gives {"aaa" 2 1}
sort sort the content of the list.
works for number and string
{ 5 "aa" 3 "bb" 6 } gives {3 5 6 "aa" "bb"}
add add an item to the end of the list
or concatenate two lists
{ 1 2 } 3 add gives {1 2 3}
{1 2} {3 4} add gives {1 2 3 4}
get Extract objects from a list

works also for strings and array
{"a" "b" "c" "d" "e"} 2 get gives { "b" }
{"a" "b" "c" "d" "e"} { 2 4 } get gives { "b" "c" "d" } ( from 2 to 4 )
sum compute the sum of all item of a list { 1 2 3 } sum gives 6
{ "aa" "b" "c" } sum gives "aabc"
len give a list of lenght of each item.
warning : this is not size
{ "aa" "bbb" } len gives {2 3}
it consider each item as string for computing len :
{ 1 1.5 "a" } len gives { 1 3 1 }
min gives a min value of a numerical list {8 2 6} min gives 2
max gives a max value of a numerical list {8 2 6} min gives 8
chr Convert a list of interger/hex into a string - this is the reversal of ASC.
the list contains the ascii code
{65 66} chr gives "AB"
{0x41 0x42} chr gives "AB"
note that 65 is equal to 0x41 in hexadecimal base.
asc give all ascii code of a string into a list "A1" asc gives {0x41 0x31}
it works also for lists :
{ "A" 1 } asc gives {0x41 0x31}
as you see 1 have been translated into string and then asc gives the ascii value 0x31 (49)
{}->[] convert a list into an array (matrix/vector)

in fact it also convert inner lists (see 2nd example)
{1 2} {}->[] gives [ 1 2 ] (an array)
{{1 2}{3 4}} {}->[] gives [[1 2][3 4]] (a matrix)
even if it's just a part, it convert it :
{[1 2]{3 4}} {}->[] gives [[1 2][3 4]] (a matrix)
min gives the lowest numerical value { 1 2 3 } min gives 1
max gives the highest numerical value { 1 2 3 } min gives 3
{}->poly Create a polymial {5 6 7} {}->poly gives 5 + 6x + 7x²
head get the first object of a list { 1 2 3 } head gives 1
{ {1 "a"} 2 3} head gives {1 "a"}
concat concatenate each list item and add separators { 1 2 3 } "x" concat gives "1x2x3"
{1 2 "z"} ";" concat gives "1;2;z"
ForEach to perform a program (see example) on each item of a list.
note : QLE script are also allowed
{1 2 3} « ^2 » gives {1 4 9}
List->Script Convert a list into a StringSource for scriptig
see Quick List Entry
{1 DUp} List->Script gives "1 \! DUP"



List usage to use a function on all items


Sorry, this is UNDER CONSTRUCTION (new style 14th Dec 2003)