-Transient iterators, that abstract on a finite sequence of elements. They
- are designed to allow easy transfer (mappings) between data structures,
- without defining n^2 conversions between the n types.
+
Transient iterators, that abstract on a finite sequence of elements.
Sequence abstract iterator type, representing a finite sequence of
values of type 'a.
+
-Cycle forever through the given sequence. Assume the
- given sequence can be traversed any amount of times (not transient).
+Cycle forever through the given sequence.
Monadic bind. It applies the function to every element of the
initial sequence, and calls concat.
-
+
val intersperse : 'a -> 'a t -> 'a t
Insert the second element between every element of the sequence
val persistent : 'a t -> 'a t
Iterate on the sequence, storing elements in a data structure.
The resulting sequence can be iterated on as many times as needed.
+
val sort : ?cmp:('a -> 'a -> int) -> 'a t -> 'a t
+Sort the sequence. Eager, O(n) ram and O(n ln(n)) time.
+
+
val sort_uniq : ?cmp:('a -> 'a -> int) -> 'a t -> 'a t
+Sort the sequence and remove duplicates. Eager, same as sort
+
+
val group : ?eq:('a -> 'a -> bool) -> 'a t -> 'a list t
+Group equal consecutive elements.
+
+
val uniq : ?eq:('a -> 'a -> bool) -> 'a t -> 'a t
+Remove consecutive duplicate elements. Basically this is
+ like fun seq -> map List.hd (group seq).
+
val product : 'a t -> 'b t -> ('a * 'b) t
Cartesian product of the sequences. The first one is transformed
by calling persistent on it, so that it can be traversed
several times (outer loop of the product)
+
val join : join_row:('a -> 'b -> 'c option) ->
'a t -> 'b t -> 'c t
+join ~join_row a b combines every element of a with every
+ element of b using join_row. If join_row returns None, then
+ the two elements do not combine. Assume that b allows for multiple
+ iterations.
+
val unfoldr : ('b -> ('a * 'b) option) -> 'b -> 'a t
unfoldr f b will apply f to b. If it
yields Some (x,b') then x is returned
and unfoldr recurses with b'.
+
val scan : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b t
+Sequence of intermediate results
+
val max : ?lt:('a -> 'a -> bool) -> 'a t -> 'a -> 'a
Max element of the sequence, using the given comparison
function. A default element has to be provided.
@@ -141,6 +188,14 @@ Drop the n first elements of the sequence
Reverse the sequence. O(n) memory and time.
+
Binary sequences
+
val empty2 : ('a, 'b) t2
val is_empty2 : ('a, 'b) t2 -> bool
val length2 : ('a, 'b) t2 -> int
val zip : ('a, 'b) t2 -> ('a * 'b) t
val unzip : ('a * 'b) t -> ('a, 'b) t2
val zip_i : 'a t -> (int, 'a) t2
+Zip elements of the sequence with their index in the sequence
+
+
val fold2 : ('c -> 'a -> 'b -> 'c) -> 'c -> ('a, 'b) t2 -> 'c
val iter2 : ('a -> 'b -> unit) -> ('a, 'b) t2 -> unit
val map2 : ('a -> 'b -> 'c) -> ('a, 'b) t2 -> 'c t
val map2_2 : ('a -> 'b -> 'c) ->
('a -> 'b -> 'd) -> ('a, 'b) t2 -> ('c, 'd) t2
+map2_2 f g seq2 maps each x, y of seq2 into f x y, g x y
+
+
Basic data structures converters
val to_list : 'a t -> 'a list
val to_rev_list : 'a t -> 'a list
Get the list of the reversed sequence (more efficient)
@@ -152,12 +207,15 @@ Convert to an array. Currently not very efficient because
val of_array : 'a array -> 'a t
val of_array_i : 'a array -> (int * 'a) t
Elements of the array, with their index
-
val array_slice : 'a array -> int -> int -> 'a t
+
val of_array2 : 'a array -> (int, 'a) t2
val array_slice : 'a array -> int -> int -> 'a t
array_slice a i j Sequence of elements whose indexes range
from i to j
val of_stream : 'a Stream.t -> 'a t
-Sequence of elements of a stream
+Sequence of elements of a stream (usable only once)
+
+
val to_stream : 'a t -> 'a Stream.t
+Convert to a stream. linear in memory and time (a copy is made in memory)
val to_stack : 'a Stack.t -> 'a t -> unit
Push elements of the sequence on the stack
@@ -182,9 +240,15 @@ Add elements of the sequence to the hashtable, with
val to_hashtbl : ('a * 'b) t -> ('a, 'b) Hashtbl.t
Build a hashtable from a sequence of key/value pairs
+
val to_hashtbl2 : ('a, 'b) t2 -> ('a, 'b) Hashtbl.t
+Build a hashtable from a sequence of key/value pairs
+
val of_hashtbl : ('a, 'b) Hashtbl.t -> ('a * 'b) t
Sequence of key/value pairs from the hashtable
+
val of_hashtbl2 : ('a, 'b) Hashtbl.t -> ('a, 'b) t2
+Sequence of key/value pairs from the hashtable
+
val hashtbl_keys : ('a, 'b) Hashtbl.t -> 'a t
val hashtbl_values : ('a, 'b) Hashtbl.t -> 'b t
val of_str : string -> char t
val to_str : char t -> string
val of_in_channel : Pervasives.in_channel -> char t
val to_buffer : char t -> Buffer.t -> unit
Copy content of the sequence into the buffer
@@ -209,6 +273,8 @@ Sequence of choices of an element in the array
val random_list : 'a list -> 'a t
Type-classes
module TypeClass: sig .. end
+
Infix functions
+
module Infix: sig .. end
Pretty printing of sequences
val pp_seq : ?sep:string ->
(Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit
Pretty print a sequence of 'a, using the given pretty printer
diff --git a/api/html.stamp b/api/html.stamp
index 60d715c..929010b 100644
--- a/api/html.stamp
+++ b/api/html.stamp
@@ -1 +1 @@
-262ceaccb53cec41f6a06ae2253f2193
\ No newline at end of file
+8860b0ecfcc48b9b2fb5adef35908225
\ No newline at end of file
diff --git a/api/index_modules.html b/api/index_modules.html
index e0a460f..9c74f8f 100644
--- a/api/index_modules.html
+++ b/api/index_modules.html
@@ -25,6 +25,9 @@ Adapt a pre-existing Map module to make it sequence-aware
Create an enriched Set module from the given one
+
I |
+
| Infix [Sequence] |
+ |
M |
| Make [Sequence.Map] |
diff --git a/api/index_types.html b/api/index_types.html
index b198ee1..ff4f35c 100644
--- a/api/index_types.html
+++ b/api/index_types.html
@@ -40,6 +40,11 @@ Sequence abstract iterator type, representing a finite sequence of
values of type 'a.
|
+
| t2 [Sequence] |
+
+Sequence of pairs of values of type 'a and 'b.
+
+ |