package containers

  1. Overview
  2. Docs
On This Page
  1. Lazy List
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module CCLazy_listSource

Lazy List

  • since 0.17
Sourcetype +'a t = 'a node lazy_t
Sourceand +'a node =
  1. | Nil
  2. | Cons of 'a * 'a t
Sourceval empty : 'a t

Empty list.

Sourceval return : 'a -> 'a t

Return a computed value.

Sourceval is_empty : _ t -> bool

Evaluate the head.

Sourceval length : _ t -> int

length l returns the number of elements in l, eagerly (linear time). Caution, will not terminate if l is infinite.

Sourceval cons : 'a -> 'a t -> 'a t
Sourceval head : 'a t -> ('a * 'a t) option

Evaluate head, return it, or None if the list is empty.

Sourceval map : f:('a -> 'b) -> 'a t -> 'b t

Lazy map.

Sourceval filter : f:('a -> bool) -> 'a t -> 'a t

Filter values.

  • since 0.18
Sourceval take : int -> 'a t -> 'a t

Take at most n values.

  • since 0.18
Sourceval append : 'a t -> 'a t -> 'a t

Lazy concatenation.

Sourceval flat_map : f:('a -> 'b t) -> 'a t -> 'b t

Monadic flatten + map.

Sourceval default : default:'a t -> 'a t -> 'a t

Choice operator.

  • since 2.1
Sourcemodule Infix : sig ... end
include module type of Infix
Sourceval (>|=) : 'a t -> ('a -> 'b) -> 'b t
Sourceval (>>=) : 'a t -> ('a -> 'b t) -> 'b t
Sourceval (<|>) : 'a t -> 'a t -> 'a t

Alias to default.

  • since 2.1
Sourcetype 'a gen = unit -> 'a option
Sourceval of_gen : 'a gen -> 'a t
Sourceval of_list : 'a list -> 'a t
Sourceval to_list : 'a t -> 'a list
Sourceval to_list_rev : 'a t -> 'a list
Sourceval to_gen : 'a t -> 'a gen
OCaml

Innovation. Community. Security.