W Wrapl, The Programming Language

Libraries Agg.List

Types

T

A general purpose extensible list type. Lists are indexed starting at 1.

Functions

Apply(list, func) : ANY

Returns the result of calling func with the elements in list as arguments.

References to the elements of list are passed so if func expects reference parameters, it will modify list.

Collect(func @ Std.Function.T, args...) : T

Returns a list of all values produced by func(args).

CollectN(func @ Std.Function.T, list1, ..., listk) : T

Returns a list of all values produced by func(arg1, ..., argk) where arg1, ..., argk are elements taken from list1, ..., listk

Make(value1, ..., valuek) : T

returns a list with value1, ... , valuek as its elements

New(length @ Std.Integer.T = 0) : T

Returns a new list with Length elements

Methods

:"+"(a @ T, b @ T) : T

returns the concatenation of a and b

:"="(_ @ T, _ @ T, _ @ Agg.ObjectTable.T)

:"@"(list @ T, _ = Std.String.T, sep @ Std.String.T) : Std.String.T

converts each element of list to a string and joins them separating elements with sep.

:"@"(_ @ T, _ = Std.String.T)

:"[]"(list @ T, n @ Std.Integer.SmallT) : ANY

returns an assignable reference to the nth element of list

negative indices are taken from the end of the list

fails if n is outside the range -list:length .. list:length

:"[]"(list @ T, m @ Std.Integer.SmallT, n @ Std.Integer.SmallT) : ANY

returns the sublist of list from the mth to the n - 1th element inclusively

fails if either m or n is outside the range of the list

returns an empty list if m > n

:"[]="(list @ T, n @ Std.Integer.SmallT, value) : ANY

compares the nth element of list to value

negative indices are taken from the end of the list

fails if n is outside the range -list:length .. list:length

:"[]="(list @ T, m @ Std.Integer.SmallT, n @ Std.Integer.SmallT, list2 @ T) : T

compares the sublist of list from the mth to the n - 1th element inclusively to list2

fails if either m or n is outside the range of the list

returns an empty list if m > n

:apply(func @ Std.Function.T, list @ T) : ANY

Returns the result of calling func with the elements in list as arguments.

References to the elements of list are passed so if func expects reference parameters, it will modify list.

:apply(list @ T, func @ Std.Function.T) : ANY

Returns the result of calling func with the elements in list as arguments.

References to the elements of list are passed so if func expects reference parameters, it will modify list.

:bsearch(_ @ T, _)

:collect(_ @ Std.Function.T, _)

:copy(list @ T) : T

returns a shallow copy of list

:delete(list @ T, n @ Std.Integer.SmallT) : ANY

removes the nth element from list. Returns the removed value.

:empty(list @ T) : T

empties list and returns it

:fill(list @ T, var1+, ..., vark+)

Iterates through list assigning values to var1, ..., vark, k values at a time,

:find(list @ T, value, fn1+, ..., fnk+) : Std.Integer.SmallT

Generates all n where fnk( ... fn1(list[n]) ... ) = value, if any.

:find(list @ T, value) : Std.Integer.SmallT

Generates all n where list[n] = value, if any.

:foldl(_ @ T, _ @ Std.Function.T)

:foldl(_ @ Std.Function.T, _ @ T)

:foldr(_ @ T, _ @ Std.Function.T)

:foldr(_ @ Std.Function.T, _ @ T)

:in(value, list @ T) : ANY

Returns value if it is an element in list, fails otherwise.

:insert(list @ T, n @ Std.Integer.SmallT, value...) : T

inserts value... into the nth position in list

:keys(list @ T) : Std.Integer.SmallT

Equivalent to 1:to(list:length).

:length(list @ T) : Std.Integer.SmallT

returns the length of list

:loop(_ @ T, _, _)

:map(func @ Std.Function.T, list @ T) : T

Returns the list or results obtained by calling func with each element in list.

Elements for which func(value) fail will not add any result to the list.

:map(list @ T, func @ Std.Function.T) : T

Returns the list or results obtained by calling func with each element in list.

Elements for which func(value) fail will not add any result to the list.

:new(_ = T)

:pop(list @ T) : ANY

removes and returns the first element of list

:pull(list @ T) : ANY

removes and returns the last element of list

:push(list @ T, value...) : T

inserts value... onto the start of list and returns list

:put(list @ T, value...) : T

inserts value... onto the end of list and returns list

:remove(list @ T, value, _) : ANY

Removes the first occurance where fnk( ... fn1(list[n]) ... ) = value from list.

Returns value if value was removed, fails otherwise.

:remove(list @ T, value) : ANY

Removes the first occurance of value from list.

Returns value if value was present, fails otherwise.

:remove_if(list @ T, func @ Std.Function.T) : ANY

Removes the first value from list for which func(value) succeeds.

Returns value if such a value was found, fails otherwise.

:reverse(list @ T) : T

Reverses the order of the entries in list in place. Returns list.

:rfind(list @ T, value, fn1+, ..., fnk+) : Std.Integer.SmallT

Generates all n where fnk( ... fn1(list[n]) ... ) = value in reverse order, if any.

:rfind(list @ T, value) : Std.Integer.SmallT

Generates all n where list[n] = value in reverse order, if any.

:rvalues(list @ T) : ANY

Generates the values in list in reverse order.

:rwhere(list @ T, predicate @ Std.Function.T, value) : Std.Integer.SmallT

Generates all n where predicate(list[n]) = value in reverse order, if any.

:rwhere(list @ T, predicate @ Std.Function.T) : Std.Integer.SmallT

Generates all n where predicate(list[n]) succeeds in reverse order, if any.

:shift(list @ T, n @ Std.Integer.SmallT, r @ Std.Integer.SmallT) : T

shifts the nth element by r positions within list

:size(list @ T) : Std.Integer.SmallT

returns the length of list

:sort(list @ T, comp @ Std.Function.T) : T

Sorts list in place with the ordering given by a < b if comp(a, b) succeeds.

Algorithm taken from Simon Tatham's Algorithms Page

:sort(list @ T) : T

Sorts list in place with the ordering given by a < b if comp(a, b) succeeds.

Algorithm taken from Simon Tatham's Algorithms Page

:sort2(list @ T, comp @ Std.Function.T) : T

Code based on public domain code by Philip J. Erdelsky, pje@acm.org

http://www.alumni.caltech.edu/~pje/

:sort2(list @ T) : T

Code based on public domain code by Philip J. Erdelsky, pje@acm.org

http://www.alumni.caltech.edu/~pje/

:split(list @ T, from @ Std.Integer.SmallT, to @ Std.Integer.SmallT) : T

Trims the list to list[1, from - 1] + list[to, 0] and returns list[from, to - 1].

:split(list @ T, from @ Std.Integer.SmallT) : T

Trims the list to list[1, from - 1] and returns list[from, 0].

:values(list @ T) : ANY

Generates the values in list.

:where(list @ T, predicate @ Std.Function.T, value) : Std.Integer.SmallT

Generates all n where predicate(list[n]) = value, if any.

:where(list @ T, predicate @ Std.Function.T) : Std.Integer.SmallT

Generates all n where predicate(list[n]) succeeds, if any.