diff --git a/api/Sequence.Infix.html b/api/Sequence.Infix.html new file mode 100644 index 0000000..3b0c65b --- /dev/null +++ b/api/Sequence.Infix.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + +Sequence.Infix + + + +

Module Sequence.Infix

+
module Infix: sig .. end

+
val (--) : int -> int -> int Sequence.t
val (|>) : 'a -> ('a -> 'b) -> 'b
val (@@) : 'a Sequence.t -> 'a Sequence.t -> 'a Sequence.t
\ No newline at end of file diff --git a/api/Sequence.TypeClass.html b/api/Sequence.TypeClass.html index d0bc842..d2512ae 100644 --- a/api/Sequence.TypeClass.html +++ b/api/Sequence.TypeClass.html @@ -5,6 +5,7 @@ + @@ -17,7 +18,8 @@ Next +

Module Sequence.TypeClass

module TypeClass: sig .. end

type ('a, 'b) sequenceable = {
diff --git a/api/Sequence.html b/api/Sequence.html index 3454c9c..92b0273 100644 --- a/api/Sequence.html +++ b/api/Sequence.html @@ -12,11 +12,13 @@ + +Sequence @@ -25,22 +27,43 @@  

Module Sequence

module Sequence: sig .. end
-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.



-
type +'a t 
+
+The iterators are designed to allow easy transfer (mappings) between data + structures, without defining n^2 conversions between the n types. The + implementation relies on the assumption that a sequence can be iterated + on as many times as needed; this choice allows for high performance + of many combinators. However, for transient iterators, the Sequence.persistent + function is provided, storing elements of a transient iterator + in memory; the iterator can then be used several times. +

+ + Note that some combinators also return sequences (e.g. Sequence.group). The + transformation is computed on the fly every time one iterates over + the resulting sequence. If a transformation performs heavy computation, + Sequence.persistent can also be used as intermediate storage.
+

type 'a t = ('a -> unit) -> unit 
Sequence abstract iterator type, representing a finite sequence of values of type 'a.
+
type ('a, 'b) t2 = ('a -> 'b -> unit) -> unit 
+
+Sequence of pairs of values of type 'a and 'b.
+
+

Build a sequence


val from_iter : (('a -> unit) -> unit) -> 'a t
Build a sequence from a iter function
+
val from_fun : (unit -> 'a option) -> 'a t
+Call the function repeatedly until it returns None. This + sequence is transient, use Sequence.persistent if needed!
+
val empty : 'a t
Empty sequence
@@ -57,8 +80,7 @@ Infinite sequence of the same element
Sequence that calls the given function to produce elements
val cycle : 'a t -> 'a t
-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.

Consume a sequence


@@ -103,27 +125,52 @@ Append two sequences
val concat : 'a t t -> 'a t
Concatenate a sequence of sequences into one sequence
+
val flatten : 'a t t -> 'a t
+Alias for Sequence.concat
+
val flatMap : ('a -> 'b t) -> 'a t -> 'b t
Monadic bind. It applies the function to every element of the initial sequence, and calls concat.
-
val intersperse : 'a t -> 'a -> 'a t
+
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. +
+
\ No newline at end of file diff --git a/api/index_values.html b/api/index_values.html index 935d067..22e51aa 100644 --- a/api/index_values.html +++ b/api/index_values.html @@ -14,6 +14,13 @@  

Index of values

+ + + + + + + + + + + + + + + + + + + + + + @@ -140,6 +171,13 @@ Consume the sequence, passing all its arguments to the function Iterate on elements and their index in the sequence + + + @@ -149,12 +187,21 @@ Iterate on elements and their index in the sequence How long is the sequence? + + + + + + + + + + @@ -215,7 +269,7 @@ Sequence of elements of the stack (same order as Stack.iter @@ -260,6 +314,11 @@ Reverse the sequence. + + @@ -267,6 +326,16 @@ Reverse the sequence. Singleton sequence + + + + + + @@ -318,15 +392,35 @@ Push elements of the sequence on the stack + + + + + + + + + + +

(--) [Sequence.Infix]
(@@) [Sequence.Infix]
(|>) [Sequence.Infix]

A
append [Sequence]
@@ -49,6 +56,8 @@ Drop the n first elements of the sequence Empty sequence
empty2 [Sequence]
exists [Sequence]
Exists there some element satisfying the predicate? @@ -65,11 +74,18 @@ Filter on elements of the sequence Monadic bind.
flatten [Sequence]
+Alias for Sequence.concat +
+
fold [Sequence]
Fold over elements of the sequence, consuming it
fold2 [Sequence]
foldi [Sequence]
Fold over elements of the sequence and their index, consuming it @@ -85,11 +101,22 @@ Do all elements satisfy the predicate? Sequence that calls the given function to produce elements
from_fun [Sequence]
+Call the function repeatedly until it returns None. +
+
from_iter [Sequence]
Build a sequence from a iter function

G
group [Sequence]
+Group equal consecutive elements. +
+

H
hashtbl_add [Sequence]
@@ -123,11 +150,15 @@ Insert the second element between every element of the sequence Is the sequence empty?
is_empty2 [Sequence]
iter [Sequence]
Consume the sequence, passing all its arguments to the function
iter2 [Sequence]
iterable [Sequence.TypeClass]
iterate [Sequence]

J
join [Sequence]
+join ~join_row a b combines every element of a with every + element of b using join_row. +
+

K
keys [Sequence.Map.S]
length2 [Sequence]

M
map [Sequence]
Map objects of the sequence into other elements, lazily
map2 [Sequence]
map2_2 [Sequence]
+map2_2 f g seq2 maps each x, y of seq2 into f x y, g x y +
+
mapi [Sequence]
Map objects, along with their index in the sequence @@ -176,6 +223,8 @@ Min element of the sequence, using the given comparison function

O
of_array [Sequence]
of_array2 [Sequence]
of_array_i [Sequence]
Elements of the array, with their index @@ -186,6 +235,11 @@ Elements of the array, with their index Sequence of key/value pairs from the hashtable
of_hashtbl2 [Sequence]
+Sequence of key/value pairs from the hashtable +
+
of_in_channel [Sequence]
of_iterable [Sequence.TypeClass]
of_stream [Sequence]
-Sequence of elements of a stream +Sequence of elements of a stream (usable only once)

P

S
scan [Sequence]
+Sequence of intermediate results +
+
sequenceable [Sequence.TypeClass]
singleton [Sequence]
sort [Sequence]
+Sort the sequence. +
+
sort_uniq [Sequence]
+Sort the sequence and remove duplicates. +
+

T
take [Sequence]
@@ -290,6 +359,11 @@ Copy content of the sequence into the buffer Build a hashtable from a sequence of key/value pairs
to_hashtbl2 [Sequence]
+Build a hashtable from a sequence of key/value pairs +
+
to_list [Sequence]
to_queue [Sequence]
to_str [Sequence]
to_stream [Sequence]
+Convert to a stream. +
+

U
unfoldr [Sequence]
unfoldr f b will apply f to b.
uniq [Sequence]
+Remove consecutive duplicate elements. +
+
unzip [Sequence]

V
values [Sequence.Map.S]

Z
zip [Sequence]
zip_i [Sequence]
+Zip elements of the sequence with their index in the sequence +
+
\ No newline at end of file diff --git a/api/type_Sequence.Infix.html b/api/type_Sequence.Infix.html new file mode 100644 index 0000000..0006b96 --- /dev/null +++ b/api/type_Sequence.Infix.html @@ -0,0 +1,16 @@ + + + + + + + + +Sequence.Infix + + +sig
+  val ( -- ) : int -> int -> int Sequence.t
+  val ( |> ) : '-> ('-> 'b) -> 'b
+  val ( @@ ) : 'Sequence.t -> 'Sequence.t -> 'Sequence.t
+end
\ No newline at end of file diff --git a/api/type_Sequence.html b/api/type_Sequence.html index 36346a6..8fc6cf3 100644 --- a/api/type_Sequence.html +++ b/api/type_Sequence.html @@ -10,8 +10,10 @@ sig
-  type +'a t
+  type 'a t = ('-> unit) -> unit
+  type ('a, 'b) t2 = ('-> '-> unit) -> unit
  val from_iter : (('-> unit) -> unit) -> 'Sequence.t
+  val from_fun : (unit -> 'a option) -> 'Sequence.t
  val empty : 'Sequence.t
  val singleton : '-> 'Sequence.t
  val repeat : '-> 'Sequence.t
@@ -31,24 +33,47 @@   val filter : ('-> bool) -> 'Sequence.t -> 'Sequence.t
  val append : 'Sequence.t -> 'Sequence.t -> 'Sequence.t
  val concat : 'Sequence.t Sequence.t -> 'Sequence.t
+  val flatten : 'Sequence.t Sequence.t -> 'Sequence.t
  val flatMap : ('-> 'Sequence.t) -> 'Sequence.t -> 'Sequence.t
-  val intersperse : 'Sequence.t -> '-> 'Sequence.t
+  val intersperse : '-> 'Sequence.t -> 'Sequence.t
  val persistent : 'Sequence.t -> 'Sequence.t
+  val sort : ?cmp:('-> '-> int) -> 'Sequence.t -> 'Sequence.t
+  val sort_uniq : ?cmp:('-> '-> int) -> 'Sequence.t -> 'Sequence.t
+  val group : ?eq:('-> '-> bool) -> 'Sequence.t -> 'a list Sequence.t
+  val uniq : ?eq:('-> '-> bool) -> 'Sequence.t -> 'Sequence.t
  val product : 'Sequence.t -> 'Sequence.t -> ('a * 'b) Sequence.t
+  val join :
+    join_row:('-> '-> 'c option) ->
+    'Sequence.t -> 'Sequence.t -> 'Sequence.t
  val unfoldr : ('-> ('a * 'b) option) -> '-> 'Sequence.t
+  val scan : ('-> '-> 'b) -> '-> 'Sequence.t -> 'Sequence.t
  val max : ?lt:('-> '-> bool) -> 'Sequence.t -> '-> 'a
  val min : ?lt:('-> '-> bool) -> 'Sequence.t -> '-> 'a
  val take : int -> 'Sequence.t -> 'Sequence.t
  val drop : int -> 'Sequence.t -> 'Sequence.t
  val rev : 'Sequence.t -> 'Sequence.t
+  val empty2 : ('a, 'b) Sequence.t2
+  val is_empty2 : ('a, 'b) Sequence.t2 -> bool
+  val length2 : ('a, 'b) Sequence.t2 -> int
+  val zip : ('a, 'b) Sequence.t2 -> ('a * 'b) Sequence.t
+  val unzip : ('a * 'b) Sequence.t -> ('a, 'b) Sequence.t2
+  val zip_i : 'Sequence.t -> (int, 'a) Sequence.t2
+  val fold2 : ('-> '-> '-> 'c) -> '-> ('a, 'b) Sequence.t2 -> 'c
+  val iter2 : ('-> '-> unit) -> ('a, 'b) Sequence.t2 -> unit
+  val map2 : ('-> '-> 'c) -> ('a, 'b) Sequence.t2 -> 'Sequence.t
+  val map2_2 :
+    ('-> '-> 'c) ->
+    ('-> '-> 'd) -> ('a, 'b) Sequence.t2 -> ('c, 'd) Sequence.t2
  val to_list : 'Sequence.t -> 'a list
  val to_rev_list : 'Sequence.t -> 'a list
  val of_list : 'a list -> 'Sequence.t
  val to_array : 'Sequence.t -> 'a array
  val of_array : 'a array -> 'Sequence.t
  val of_array_i : 'a array -> (int * 'a) Sequence.t
+  val of_array2 : 'a array -> (int, 'a) Sequence.t2
  val array_slice : 'a array -> int -> int -> 'Sequence.t
  val of_stream : 'Stream.t -> 'Sequence.t
+  val to_stream : 'Sequence.t -> 'Stream.t
  val to_stack : 'Stack.t -> 'Sequence.t -> unit
  val of_stack : 'Stack.t -> 'Sequence.t
  val to_queue : 'Queue.t -> 'Sequence.t -> unit
@@ -56,7 +81,9 @@   val hashtbl_add : ('a, 'b) Hashtbl.t -> ('a * 'b) Sequence.t -> unit
  val hashtbl_replace : ('a, 'b) Hashtbl.t -> ('a * 'b) Sequence.t -> unit
  val to_hashtbl : ('a * 'b) Sequence.t -> ('a, 'b) Hashtbl.t
+  val to_hashtbl2 : ('a, 'b) Sequence.t2 -> ('a, 'b) Hashtbl.t
  val of_hashtbl : ('a, 'b) Hashtbl.t -> ('a * 'b) Sequence.t
+  val of_hashtbl2 : ('a, 'b) Hashtbl.t -> ('a, 'b) Sequence.t2
  val hashtbl_keys : ('a, 'b) Hashtbl.t -> 'Sequence.t
  val hashtbl_values : ('a, 'b) Hashtbl.t -> 'Sequence.t
  val of_str : string -> char Sequence.t
@@ -298,6 +325,12 @@       val to_addable :
        ('a, 'b) Sequence.TypeClass.addable -> 'Sequence.t -> 'b
    end
+  module Infix :
+    sig
+      val ( -- ) : int -> int -> int Sequence.t
+      val ( |> ) : '-> ('-> 'b) -> 'b
+      val ( @@ ) : 'Sequence.t -> 'Sequence.t -> 'Sequence.t
+    end
  val pp_seq :
    ?sep:string ->
    (Format.formatter -> '-> unit) ->