Wrapl, The Programming Language

Libraries/Std/List

Types

T

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

Functions

Collect(func @ Std.Function.T) : 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()

Make2(value1,...valuek) : T

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

New()

New2(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, _ = 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) : T

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

: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.

:collect(func @ Std.Function.T) : T

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

:copy(list @ T) : T

returns a shallow copy of list

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

removes the nth element from list

:empty(list @ T) : T

empties list and returns it

: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) : Std.Integer.SmallT

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

: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(list @ T, var1,...vark)

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

: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.

: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 of value from list.

Succeeds if value was present, fails otherwise.

:rvalues(list @ T) : ANY

Generates the values in list in reverse order.

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

shifts the nth element by n 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

:values(list @ T) : ANY

Generates the values in list.

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

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