Module Sek__.Adapters
type ('a, 'c) iter
= ('a -> unit) -> 'c -> unit
('a, 'c) iter
is the conventional type of aniter
function that iterates over a collection of type'c
whose elements have type'a
.
type ('a, 'c) iteri
= (int -> 'a -> unit) -> 'c -> unit
('a, 'c) iter
is the conventional type of aniteri
function that iterates over a collection of type'c
whose elements have type'a
.
type ('a, 'b, 'c) fold_left
= ('b -> 'a -> 'b) -> 'b -> 'c -> 'b
('a, 'b, 'c) fold_left
is the conventional type of afold_left
function that iterates over a collection of type'c
whose elements have type'a
and that carries an accumulator of type'b
. The accumulator is the first argument of the user function that represents the loop body. By convention, if the collection represents a sequence, then iteration should be performed left-to-right.
type ('a, 'b, 'c) fold_right
= ('a -> 'b -> 'b) -> 'c -> 'b -> 'b
('a, 'b, 'c) fold_right
is the conventional type of afold_right
function that iterates over a collection of type'c
whose elements have type'a
and that carries an accumulator of type'b
. The accumulator is the second argument of the user function that represents the loop body. By convention, if the collection represents a sequence, then iteration should be performed right-to-left.
val fold_left : ('a, 'c) iter -> ('a, 'b, 'c) fold_left
fold_left
transforms aniter
function, which should perform left-to-right iteration, into afold_left
function.
val fold_right : ('a, 'c) iter -> ('a, 'b, 'c) fold_right
fold_right
transforms aniter
function, which should perform right-to-left iteration, into afold_right
function.
val iteri_left : ('a, 'c) iter -> ('a, 'c) iteri
iteri_left
transforms aniter
function, which should perform left-to-right iteration, into aniteri_left
function, which counts up from 0.
val iteri_right : ('c -> int) -> ('a, 'c) iter -> ('a, 'c) iteri
iteri_right
requires alength
function and transforms aniter
function, which should perform right-to-left iteration, into aniteri_right
function, which counts down fromlength s - 1
.
type ('a1, 'a2, 'c1, 'c2) iter2
= ('a1 -> 'a2 -> unit) -> 'c1 -> 'c2 -> unit
('a1, 'a2, 'c1, 'c2) iter2
is the conventional type of aniter2
function that iterates synchronously over two collections of type'c1
and'c2
whose elements have types'a1
and'a2
, respectively.
type ('a1, 'a2, 'b, 'c1, 'c2) fold_left2
= ('b -> 'a1 -> 'a2 -> 'b) -> 'b -> 'c1 -> 'c2 -> 'b
('a1, 'a2, 'b 'c1, 'c2) fold_left2
is the conventional type of afold_left2
function that iterates synchronously over two collections of type'c1
and'c2
whose elements have types'a1
and'a2
, respectively, while maintaining an accumulator of type'b
. By convention, if the collection represents a sequence, then iteration should be performed left-to-right.
type ('a1, 'a2, 'b, 'c1, 'c2) fold_right2
= ('a1 -> 'a2 -> 'b -> 'b) -> 'c1 -> 'c2 -> 'b -> 'b
('a1, 'a2, 'b, 'c1, 'c2) fold_right2
is the conventional type of afold_right2
function that iterates synchronously over two collections of type'c1
and'c2
whose elements have types'a1
and'a2
, respectively, while maintaining an accumulator of type'b
. By convention, if the collection represents a sequence, then iteration should be performed right-to-left.
val fold_left2 : ('a1, 'a2, 'c1, 'c2) iter2 -> ('a1, 'a2, 'b, 'c1, 'c2) fold_left2
fold_left2
transforms aniter2
function, which should perform left-to-right iteration, into afold_left2
function.
val fold_right2 : ('a1, 'a2, 'c1, 'c2) iter2 -> ('a1, 'a2, 'b, 'c1, 'c2) fold_right2
fold_right2
transforms aniter2
function, which should perform right-to-left iteration, into afold_right2
function.
type ('a, 'c) to_list
= 'c -> 'a list
('a, 'c) to_list
is the conventional type of ato_list
function that converts a collection of type'c
, whose elements have type'a
, to a list.
val to_list : ('a, 'c) iter -> ('a, 'c) to_list
to_list
transforms aniter_right
function, which should perform right-to-left iteration, into ato_list
function.
type 'a iterator
= unit -> 'a
'a iterator
is the conventional type of a mutable iterator on a sequence, packaged as a functionnext
, which returns a new element of the sequence every time it is invoked, and raises the exceptionExhausted
if no more elements are available.
val iterator_of_seq : 'a Stdlib.Seq.t -> 'a iterator
iterator_of_seq
transforms a sequence (in the sense of the moduleSeq
) into a mutable iterator.
val iterator_of_list : 'a list -> 'a iterator
iterator_of_list
transforms a list into a mutable iterator.