☰
list
list
Type Parameters
Functions
collect the contents of this list into an array
create an array backed version of this sequence in case this is not array
backed. This will ensure that operations like index[] or drop perform
in constant time.
returns Sequence.this if is_array_backed.
Return this list as a list.
This is a helper function that needs to be defined because list is an heir
of Sequence.
convenience feature to work around type inference issues
NYI remove when type inference gets better
create a string representation of this Sequence including all the string
representations of its contents, separated by ',' and enclosed in '['
and ']'.
In case this Sequence is known to be `finite` or has at most (Sequence T).type
.AS_STRING_NON_FINITE_MAX_ELEMENTS elements, all elements will be shown in the
resulting string. Otherwise, only the first elements will be shown followed by
",…" as in "[1,2,3,4,5,6,7,8,9,10,…]".
To force printing of all elements of a finite `Sequence` for which `finite` is
false (which may be the case since a Sequence in general might not know that it
if finite), you may use `as_string_all`.
create a string representation of this list including all the string
representations of its contents, separated by 'sep'.
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
Type Parameters
Functions
collect the contents of this list into an array
create an array backed version of this sequence in case this is not array
backed. This will ensure that operations like index[] or drop perform
in constant time.
returns Sequence.this if is_array_backed.
Return this list as a list.
This is a helper function that needs to be defined because list is an heir
of Sequence.
convenience feature to work around type inference issues
NYI remove when type inference gets better
create a string representation of this Sequence including all the string
representations of its contents, separated by ',' and enclosed in '['
and ']'.
In case this Sequence is known to be `finite` or has at most (Sequence T).type
.AS_STRING_NON_FINITE_MAX_ELEMENTS elements, all elements will be shown in the
resulting string. Otherwise, only the first elements will be shown followed by
",…" as in "[1,2,3,4,5,6,7,8,9,10,…]".
To force printing of all elements of a finite `Sequence` for which `finite` is
false (which may be the case since a Sequence in general might not know that it
if finite), you may use `as_string_all`.
create a string representation of this list including all the string
representations of its contents, separated by 'sep'.
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
Functions
collect the contents of this list into an array
create an array backed version of this sequence in case this is not array
backed. This will ensure that operations like index[] or drop perform
in constant time.
returns Sequence.this if is_array_backed.
Return this list as a list.
This is a helper function that needs to be defined because list is an heir
of Sequence.
convenience feature to work around type inference issues
NYI remove when type inference gets better
create a string representation of this Sequence including all the string
representations of its contents, separated by ',' and enclosed in '['
and ']'.
In case this Sequence is known to be `finite` or has at most (Sequence T).type
.AS_STRING_NON_FINITE_MAX_ELEMENTS elements, all elements will be shown in the
resulting string. Otherwise, only the first elements will be shown followed by
",…" as in "[1,2,3,4,5,6,7,8,9,10,…]".
To force printing of all elements of a finite `Sequence` for which `finite` is
false (which may be the case since a Sequence in general might not know that it
if finite), you may use `as_string_all`.
create a string representation of this list including all the string
representations of its contents, separated by 'sep'.
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
collect the contents of this list into an array
create an array backed version of this sequence in case this is not array
backed. This will ensure that operations like index[] or drop perform
in constant time.
returns Sequence.this if is_array_backed.
Return this list as a list.
This is a helper function that needs to be defined because list is an heir
of Sequence.
convenience feature to work around type inference issues
NYI remove when type inference gets better
create a string representation of this Sequence including all the string
representations of its contents, separated by ',' and enclosed in '['
and ']'.
In case this Sequence is known to be `finite` or has at most (Sequence T).type
.AS_STRING_NON_FINITE_MAX_ELEMENTS elements, all elements will be shown in the
resulting string. Otherwise, only the first elements will be shown followed by
",…" as in "[1,2,3,4,5,6,7,8,9,10,…]".
To force printing of all elements of a finite `Sequence` for which `finite` is
false (which may be the case since a Sequence in general might not know that it
if finite), you may use `as_string_all`.
create a string representation of this list including all the string
representations of its contents, separated by 'sep'.
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
create an array backed version of this sequence in case this is not array
backed. This will ensure that operations like index[] or drop perform
in constant time.
returns Sequence.this if is_array_backed.
backed. This will ensure that operations like index[] or drop perform
in constant time.
returns Sequence.this if is_array_backed.
Return this list as a list.
This is a helper function that needs to be defined because list is an heir
of Sequence.
convenience feature to work around type inference issues
NYI remove when type inference gets better
create a string representation of this Sequence including all the string
representations of its contents, separated by ',' and enclosed in '['
and ']'.
In case this Sequence is known to be `finite` or has at most (Sequence T).type
.AS_STRING_NON_FINITE_MAX_ELEMENTS elements, all elements will be shown in the
resulting string. Otherwise, only the first elements will be shown followed by
",…" as in "[1,2,3,4,5,6,7,8,9,10,…]".
To force printing of all elements of a finite `Sequence` for which `finite` is
false (which may be the case since a Sequence in general might not know that it
if finite), you may use `as_string_all`.
create a string representation of this list including all the string
representations of its contents, separated by 'sep'.
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
Return this list as a list.
This is a helper function that needs to be defined because list is an heir
of Sequence.
This is a helper function that needs to be defined because list is an heir
of Sequence.
convenience feature to work around type inference issues
NYI remove when type inference gets better
create a string representation of this Sequence including all the string
representations of its contents, separated by ',' and enclosed in '['
and ']'.
In case this Sequence is known to be `finite` or has at most (Sequence T).type
.AS_STRING_NON_FINITE_MAX_ELEMENTS elements, all elements will be shown in the
resulting string. Otherwise, only the first elements will be shown followed by
",…" as in "[1,2,3,4,5,6,7,8,9,10,…]".
To force printing of all elements of a finite `Sequence` for which `finite` is
false (which may be the case since a Sequence in general might not know that it
if finite), you may use `as_string_all`.
create a string representation of this list including all the string
representations of its contents, separated by 'sep'.
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
convenience feature to work around type inference issues
NYI remove when type inference gets better
NYI remove when type inference gets better
create a string representation of this Sequence including all the string
representations of its contents, separated by ',' and enclosed in '['
and ']'.
In case this Sequence is known to be `finite` or has at most (Sequence T).type
.AS_STRING_NON_FINITE_MAX_ELEMENTS elements, all elements will be shown in the
resulting string. Otherwise, only the first elements will be shown followed by
",…" as in "[1,2,3,4,5,6,7,8,9,10,…]".
To force printing of all elements of a finite `Sequence` for which `finite` is
false (which may be the case since a Sequence in general might not know that it
if finite), you may use `as_string_all`.
create a string representation of this list including all the string
representations of its contents, separated by 'sep'.
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
create a string representation of this Sequence including all the string
representations of its contents, separated by ',' and enclosed in '['
and ']'.
In case this Sequence is known to be `finite` or has at most (Sequence T).type
.AS_STRING_NON_FINITE_MAX_ELEMENTS elements, all elements will be shown in the
resulting string. Otherwise, only the first elements will be shown followed by
",…" as in "[1,2,3,4,5,6,7,8,9,10,…]".
To force printing of all elements of a finite `Sequence` for which `finite` is
false (which may be the case since a Sequence in general might not know that it
if finite), you may use `as_string_all`.
representations of its contents, separated by ',' and enclosed in '['
and ']'.
In case this Sequence is known to be `finite` or has at most (Sequence T).type
.AS_STRING_NON_FINITE_MAX_ELEMENTS elements, all elements will be shown in the
resulting string. Otherwise, only the first elements will be shown followed by
",…" as in "[1,2,3,4,5,6,7,8,9,10,…]".
To force printing of all elements of a finite `Sequence` for which `finite` is
false (which may be the case since a Sequence in general might not know that it
if finite), you may use `as_string_all`.
create a string representation of this list including all the string
representations of its contents, separated by 'sep'.
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
create a string representation of this list including all the string
representations of its contents, separated by 'sep'.
representations of its contents, separated by 'sep'.
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
create a new list that contains the first elements of
this Sequence for which 'f e' is false
this Sequence for which 'f e' is false
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
§
create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
create a new list from the result of applying 'f' to the
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
elements all combinations of elements of this list and
all elements of 'b' iterating of 'b' repeatedly as follows
list.this[0] , b[0]
list.this[0] , b[1]
list.this[0] , b[2]
list.this[0] , ...
list.this[0] , b.last
list.this[1] , b[0]
list.this[1] , b[1]
list.this[1] , ...
... , ...
list.this.last, b.last
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
Lazy list concatenation, O(1)
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
t is evaluated only when this list is exhausted
This is useful when doing buffered reading from an input
source and the next buffer chunk, the tail should only
be created when actually necessary.
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
List concatenation, O(count)
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
by all the elements of s
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
does the Sequence contain element x?
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
count the elements of this list
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
get the number of matches of l
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'
is 'nil', returns 'nil'
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).
if the list is shorter than n).
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
Lazily drop the first elements of a list for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
i.e. the square of the sum of squares of this sequence
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
Lazily filter the elements of a list.
The result contains exactly those elements for which p
is true.
The result contains exactly those elements for which p
is true.
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
is this sequence known to be finite? For infinite sequences, features like
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
count diverge.
TRUE = known finite
FALSE = known infinite
nil = unknown
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
get the first element of this Sequence or default if sequence is empty
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
get the head of this list
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
Then flatten the result by one level,
essentially combining all the sequences.
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
map the list to a new list applying function f to all elements
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
and flatten the result of f in the process
This performs a lazy mapping, f is called only when the elements
are taken from the list.
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
fold the elements of this list using the given monoid.
e.g., to sum the elements of a list of i32, use l.fold i32.sum
e.g., to sum the elements of a list of i32, use l.fold i32.sum
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
fold the elements of this list using the given monoid and initial value
Used to fold a list tail-recursively
Used to fold a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
fold the elements of this non-empty list using the given function
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
e.g., to find the minimum of a list of i32, use `l.fold1 (<=)`
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
fold the elements of this list using the given function
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
e.g., to find the product of a list of i32, use `s.foldf (*) 1`
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
call f in order on all elements of this list
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
apply 'f' to each element 'e' as long as 'f e'
get the head of this list if it exists, nil if it does
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
get the head of this list if it exists, nil if it does
not exist
not exist
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
adds the corresponding index to
every element in the sequence
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
adds an index to every element
in the sequence starting at start_idx
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
infix operand synonym for concat
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
filter elements using predicate f, infix operator
synonym of filter.
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
check if predicate f holds for all elements
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
check if predicate f holds for at least one element
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
returns the list of all but the last element of this list
list must not be empty, causes precondition failure if debug is enabled.
list must not be empty, causes precondition failure if debug is enabled.
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
insert element v at position at
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
add an element sep between every element of this list.
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
like index[] are fast.
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
is this list empty?
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
get the last element of this Sequence or default if sequence is empty
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
get the last element of this list
This may take time in O(count), in particular, it may not terminate
for an infinite list.
This may take time in O(count), in particular, it may not terminate
for an infinite list.
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
map the list to a new list applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the list.
This performs a lazy mapping, f is called only when the elements
are taken from the list.
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
maximum value in the sequence
the median of the sequence
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
the median of the sequence
https://en.wikipedia.org/wiki/Median
https://en.wikipedia.org/wiki/Median
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
minimum value in the sequence
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
add an element sep in front of every element of this list.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) => outcome R [Inherited from Sequence]reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
§
(R
type
, init R, f Binary (choice R (abort (outcome R))) R Sequence.T) =>
outcome R [Inherited from Sequence]
reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
§
replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64) => list Sequence.T [Inherited from Sequence]replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
§
(old Sequence Sequence.T, new Sequence Sequence.T, n u64)
=>
list Sequence.T [Inherited from Sequence]
replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
reverse the order of the elements in this Sequence
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
reverse the order of the elements in this list
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
all prefixes using the given monoid and initial value
Used to scan a list tail-recursively
list provides an abstract type for a sequence of elements of the same type.
A list sequence may be empty and contain no element, or it may have a fixed
or even an infinite number of elements.
The core of the implementation of an actual list lies in the implementation
of the actual Cons cell a non-empty list consists of.
Lists can typically be traversed using only immutable data. This makes them
more flexible than streams that require to store and update their state.
A list is immutable, so it can be reused and shared between threads.
Due to the nature of lists, in which many Cons cells are used, a list
may require more (heap) allocation than an array.