module CCRAL:sig
..end
This is an OCaml implementation of Okasaki's paper "Purely Functional Random Access Lists". It defines a list-like data structure with O(1) cons/tail operations, and O(log(n)) lookup/modification operations.
This module used to be part of containers.misc
status: stable
Since 0.13
type +'a
t
val empty : 'a t
val is_empty : 'a t -> bool
val cons : 'a -> 'a t -> 'a t
val return : 'a -> 'a t
val map : f:('a -> 'b) -> 'a t -> 'b t
val mapi : f:(int -> 'a -> 'b) -> 'a t -> 'b t
val hd : 'a t -> 'a
Invalid_argument
if the list is emptyval tl : 'a t -> 'a t
Invalid_argument
if the list is emptyval front : 'a t -> ('a * 'a t) option
val front_exn : 'a t -> 'a * 'a t
val length : 'a t -> int
val get : 'a t -> int -> 'a option
get l i
accesses the i
-th element of the list. O(log(n)).val get_exn : 'a t -> int -> 'a
val set : 'a t -> int -> 'a -> 'a t
set l i v
sets the i
-th element of the list to v
. O(log(n)).Invalid_argument
if the list has less than i+1
elements.val remove : 'a t -> int -> 'a t
remove l i
removes the i
-th element of v
.Invalid_argument
if the list has less than i+1
elements.val append : 'a t -> 'a t -> 'a t
val filter : f:('a -> bool) -> 'a t -> 'a t
val filter_map : f:('a -> 'b option) -> 'a t -> 'b t
val flat_map : ('a -> 'b t) -> 'a t -> 'b t
val flatten : 'a t t -> 'a t
val app : ('a -> 'b) t -> 'a t -> 'b t
val take : int -> 'a t -> 'a t
val take_while : f:('a -> bool) -> 'a t -> 'a t
val drop : int -> 'a t -> 'a t
val drop_while : f:('a -> bool) -> 'a t -> 'a t
val take_drop : int -> 'a t -> 'a t * 'a t
take_drop n l
splits l
into a, b
such that length a = n
if length l >= n
, and such that append a b = l
val iter : f:('a -> unit) -> 'a t -> unit
val iteri : f:(int -> 'a -> unit) -> 'a t -> unit
val fold : f:('b -> 'a -> 'b) -> x:'b -> 'a t -> 'b
val fold_rev : f:('b -> 'a -> 'b) -> x:'b -> 'a t -> 'b
val rev_map : f:('a -> 'b) -> 'a t -> 'b t
rev_map f l
is the same as map f (rev l)
val rev : 'a t -> 'a t
val equal : ?eq:('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val compare : ?cmp:('a -> 'a -> int) -> 'a t -> 'a t -> int
val make : int -> 'a -> 'a t
val repeat : int -> 'a t -> 'a t
repeat n l
is append l (append l ... l)
n
timesval range : int -> int -> int t
range i j
is i; i+1; ... ; j
or j; j-1; ...; i
type'a
sequence =('a -> unit) -> unit
type'a
gen =unit -> 'a option
val add_list : 'a t -> 'a list -> 'a t
val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list
val of_list_map : f:('a -> 'b) -> 'a list -> 'b t
val of_array : 'a array -> 'a t
val add_array : 'a t -> 'a array -> 'a t
val to_array : 'a t -> 'a array
val add_seq : 'a t -> 'a sequence -> 'a t
val of_seq : 'a sequence -> 'a t
val to_seq : 'a t -> 'a sequence
val add_gen : 'a t -> 'a gen -> 'a t
val of_gen : 'a gen -> 'a t
val to_gen : 'a t -> 'a gen
module Infix:sig
..end
include CCRAL.Infix
type'a
printer =Format.formatter -> 'a -> unit
val print : ?sep:string -> 'a printer -> 'a t printer