ListTest
>closedll("lists");
>tccompile lists
>load lists
This class uses a dynamic library to implement global variables and
lists in Euler.
>help lists
Euler file lists.e found.
File contains the following definitions:
This class uses a dynamic library to implement global variables and
lists in Euler.
function comment globalset (name:string, object)
## Set the a global library variable.
function comment globalget (name:string)
## Get a global library variable.
function comment makelist (name:string)
## Creates a new list with this name or resets the list.
function comment listadd (name:string, object)
## Adds an object to the list.
function comment listsize (name:string)
## The length of the list
function comment listget (name:string, i:index)
## Gets object number i from the list.
function comment listremove (name:string, i:index)
## Removes object number i from the list.
function comment removelist (name:string)
## Removes a list
function comment removeall ()
## Remove all lists and release the memory.
function comment listglobals ()
## List all global variables in the library (unsorted).
function comment listlists ()
## List all lists in the library (unsorted).
>globalset("v",1:20);
>globalget("v")
[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ]
>globalset("v",9)
>globalget("v")
9
>listglobals()
v
>makelist("test");
>loop 1 to 1000; listadd("test",random()); end;
>listsize("test")
1000
>removelist("test");
>n=100;
>function list(n) := "list"+printf("%04g",n);
>loop 1 to n; makelist(list(#)); end;
>k=intrandom(1,10000,n);
>for j=k; listadd(list(j),random()); end;
>sum=0; loop 1 to n; sum=sum+listsize(list(#)); end; sum,
10000
>sort(listlists())
list0001
list0002
list0003
list0004
list0005
list0006
list0007
list0008
list0009
list0010
list0011
list0012
list0013
list0014
list0015
list0016
list0017
list0018
list0019
list0020
list0021
list0022
list0023
list0024
list0025
list0026
list0027
list0028
list0029
list0030
list0031
list0032
list0033
list0034
list0035
list0036
list0037
list0038
list0039
list0040
list0041
list0042
list0043
list0044
list0045
list0046
list0047
list0048
list0049
list0050
list0051
list0052
list0053
list0054
list0055
list0056
list0057
list0058
list0059
list0060
list0061
list0062
list0063
list0064
list0065
list0066
list0067
list0068
list0069
list0070
list0071
list0072
list0073
list0074
list0075
list0076
list0077
list0078
list0079
list0080
list0081
list0082
list0083
list0084
list0085
list0086
list0087
list0088
list0089
list0090
list0091
list0092
list0093
list0094
list0095
list0096
list0097
list0098
list0099
list0100
>removeall();