package pyml

  1. Overview
  2. Docs

Interface for Python values of type Iter.

val check : Object.t -> bool

check o returns true if o is an iterator.

val next : Object.t -> Object.t option

next i returns the next value from the iteration i. If there are no remaining values, returns None. Wrapper for PyIter_Next.

val iter : (Object.t -> unit) -> Object.t -> unit

iter f i iteratively calls f v with all the remaining values of the iteration i.

val to_list : Object.t -> Object.t list

to_list i returns the list of all the remaining values from the iteration i.

val to_list_map : (Object.t -> 'a) -> Object.t -> 'a list

to_list_map f i returns the list of the results of f applied to all the remaining values from the iteration i. to_list_map f s is equivalent to List.map f (to_list s) but is tail-recursive and f is applied to the elements of s in the reverse order.

of_seq s returns an interator that iterates over the values of the sequence s.

val of_seq_map : ('a -> Object.t) -> 'a Stdcompat.Seq.t -> Object.t

of_seq_map f s returns an interator that iterates over the results of f applied to the values of the sequence s. Py.Iter.of_seq_map f s is equivalent to Py.Iter.of_seq (Seq.map f s).

to_seq i returns the sequence of the values from the iteration i. The Python iteration is consumed while the sequence is browsed. Values are memoized, so that the sequence can be browsed many times.

val to_seq_map : (Object.t -> 'a) -> Object.t -> 'a Stdcompat.Seq.t

to_seq_map f i returns the sequence of the results of f applied to the values from the iteration i. The Python iteration is consumed while the sequence is browsed. Values are memoized, so that the sequence can be browsed many times.

val unsafe_to_seq : Object.t -> Object.t Stdcompat.Seq.t

unsafe_to_seq i returns the sequence of the values from the iteration i. The Python iteration is consumed while the sequence is browsed. Warning: values are not memoized, so that the sequence can be browsed only once.

val unsafe_to_seq_map : (Object.t -> 'a) -> Object.t -> 'a Stdcompat.Seq.t

unsafe_to_seq_map f i returns the sequence of the results of f applied to the values from the iteration i. The Python iteration is consumed while the sequence is browsed. Warning: values are not memoized, so that the sequence can be browsed only once.

val of_list : Object.t list -> Object.t

of_list l returns an interator that iterates over the values of the list l.

val of_list_map : ('a -> Object.t) -> 'a list -> Object.t

of_list_map f l returns an interator that iterates over the results of f applied to the values of the list l. Py.Iter.of_list_map f s is equivalent to Py.Iter.of_list (List.map f s) but is tail-recursive.

val fold_left : ('a -> Object.t -> 'a) -> 'a -> Object.t -> 'a

fold_left f v i returns (f (...(f v i1)...) in) where i1, ..., in are the remaining values from the iteration i.

val fold_right : (Object.t -> 'a -> 'a) -> Object.t -> 'a -> 'a

fold_right f i v returns (f i1 (...(f v in)...) where i1, ..., in are the remaining values from the iteration i. This function is not tail-recursive.

val for_all : (Object.t -> bool) -> Object.t -> bool

for_all p i checks if p holds for all the remaining values from the iteration i.

val exists : (Object.t -> bool) -> Object.t -> bool

exists p i checks if p holds for at least one of the remaining values from the iteration i.

val create : (unit -> Object.t option) -> Object.t

create next returns an iterator that calls next.

val seq_iter : Object.t -> Object.t

Wrapper for PySeqIter_New

val call_iter : Object.t -> Object.t -> Object.t

Wrapper for PyCallIter_New

val create_call : (unit -> Object.t option) -> Object.t

create_call next returns an iterator that calls next. The difference with create is that this uses PyCallIter_New rather than creating an object and use the __next__ method.

OCaml

Innovation. Community. Security.