diff --git a/dev/containers/CCList/index.html b/dev/containers/CCList/index.html index 6fe18940..b42eb467 100644 --- a/dev/containers/CCList/index.html +++ b/dev/containers/CCList/index.html @@ -3,7 +3,7 @@ [[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];; # cartesian_product [[1;2];[];[4;5;6]] = [];; # cartesian_product [[1;2];[3];[4];[5];[6]] |> sort = -[[1;3;4;5;6];[2;3;4;5;6]];;
invariant: cartesian_product l = map_product id l.
val map_product_l : ('a -> 'b list) -> 'a list -> 'b list listmap_product_l f l maps each element of l to a list of objects of type 'b using f. We obtain [l1; l2; …; ln] where length l=n and li : 'b list. Then, it returns all the ways of picking exactly one element per li.
val diagonal : 'a t -> ('a * 'a) tdiagonal l returns all pairs of distinct positions of the list l, that is the list of List.nth i l, List.nth j l if i < j.
val partition_filter_either : ('a -> ('b, 'c) CCEither.t) -> 'a list -> 'b list * 'c listpartition_filter_either f l maps f on l and gather results in lists:
f x = Left y, adds y to the first list.f x = Right z, adds z to the second list.val partition_filter_map : ('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c listpartition_filter_map f l maps f on l and gather results in lists:
f x = `Left y, adds y to the first list.f x = `Right z, adds z to the second list.f x = `Drop, ignores x.val partition_map : ('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c listuse partition_filter_map instead
val group_by : ?hash:('a -> int) -> ?eq:('a -> 'a -> bool) -> 'a t -> 'a list tgroup_by ?hash ?eq l groups equal elements, regardless of their order of appearance. precondition: for any x and y, if eq x y then hash x=hash y must hold.
val join : join_row:('a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c tjoin ~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 join_by : ?eq:('key -> 'key -> bool) -> ?hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c tjoin_by ?eq ?hash key1 key2 ~merge la lb is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and combine values (x,y) from (a,b) with the same key using merge. If merge returns None, the combination of values is discarded. precondition: for any x and y, if eq x y then hash x=hash y must hold.
val join_all_by : ?eq:('key -> 'key -> bool) -> ?hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a list -> 'b list -> 'c option) -> 'a t -> 'b t -> 'c tjoin_all_by ?eq ?hash key1 key2 ~merge la lb is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and, for each key k occurring in at least one of them:
l1 of elements of a that map to kl2 of elements of b that map to kmerge k l1 l2. If merge returns None, the combination of values is discarded, otherwise it returns Some c and c is inserted in the result.val group_join_by : ?eq:('a -> 'a -> bool) -> ?hash:('a -> int) -> ('b -> 'a) -> 'a t -> 'b t -> ('a * 'b list) tgroup_join_by ?eq ?hash key la lb associates to every element x of the first sequence, all the elements y of the second sequence such that eq x (key y). Elements of the first sequences without corresponding values in the second one are mapped to [] precondition: for any x and y, if eq x y then hash x=hash y must hold.
val sublists_of_len : ?last:('a list -> 'a list option) -> ?offset:int -> int -> 'a list -> 'a list listsublists_of_len ?last ?offset n l returns sub-lists of l that have length n. By default, these sub-lists are non overlapping: sublists_of_len 2 [1;2;3;4;5;6] returns [1;2]; [3;4]; [5;6].
Examples:
sublists_of_len 2 [1;2;3;4;5;6] = [[1;2]; [3;4]; [5;6]].sublists_of_len 2 ~offset:3 [1;2;3;4;5;6] = [1;2];[4;5].sublists_of_len 3 ~last:CCOpt.return [1;2;3;4] = [1;2;3];[4].sublists_of_len 2 [1;2;3;4;5] = [[1;2]; [3;4]].the number of elements skipped between two consecutive sub-lists. By default it is n. If offset < n, the sub-lists will overlap; if offset > n, some elements will not appear at all.
if provided and the last group of elements g is such that length g < n, last g is called. If last g = Some g', g' is appended; otherwise g is dropped. If last = CCOpt.return, it will simply keep the last group. By default, last = fun _ -> None, i.e. the last group is dropped if shorter than n.
if offset <= 0 or n <= 0. See CCList.sublists_of_len for more details.
val chunks : int -> 'a list -> 'a list listchunks n l returns consecutives chunks of size at most n from l. Each item of l will occur in exactly one chunk. Only the last chunk might be of length smaller than n. Invariant: (chunks n l |> List.flatten) = l.
val intersperse : 'a -> 'a list -> 'a listintersperse x l inserts the element x between adjacent elements of the list l.
val interleave : 'a list -> 'a list -> 'a listinterleave [x1…xn] [y1…ym] is [x1;y1;x2;y2;…] and finishes with the suffix of the longest list.
val pure : 'a -> 'a tpure x is return x.
val mguard : bool -> unit tmguard c is pure () if c is true, [] otherwise. This is useful to define a list by comprehension, e.g.:
# let square_even xs =
+[[1;3;4;5;6];[2;3;4;5;6]];;invariant: cartesian_product l = map_product id l.
val map_product_l : ('a -> 'b list) -> 'a list -> 'b list listmap_product_l f l maps each element of l to a list of objects of type 'b using f. We obtain [l1; l2; …; ln] where length l=n and li : 'b list. Then, it returns all the ways of picking exactly one element per li.
val diagonal : 'a t -> ('a * 'a) tdiagonal l returns all pairs of distinct positions of the list l, that is the list of List.nth i l, List.nth j l if i < j.
val partition_map_either : ('a -> ('b, 'c) CCEither.t) -> 'a list -> 'b list * 'c listpartition_map_either f l maps f on l and gather results in lists:
f x = Left y, adds y to the first list.f x = Right z, adds z to the second list.val partition_filter_map : ('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c listpartition_filter_map f l maps f on l and gather results in lists:
f x = `Left y, adds y to the first list.f x = `Right z, adds z to the second list.f x = `Drop, ignores x.val partition_map : ('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c listuse partition_filter_map instead
val group_by : ?hash:('a -> int) -> ?eq:('a -> 'a -> bool) -> 'a t -> 'a list tgroup_by ?hash ?eq l groups equal elements, regardless of their order of appearance. precondition: for any x and y, if eq x y then hash x=hash y must hold.
val join : join_row:('a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c tjoin ~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 join_by : ?eq:('key -> 'key -> bool) -> ?hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c tjoin_by ?eq ?hash key1 key2 ~merge la lb is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and combine values (x,y) from (a,b) with the same key using merge. If merge returns None, the combination of values is discarded. precondition: for any x and y, if eq x y then hash x=hash y must hold.
val join_all_by : ?eq:('key -> 'key -> bool) -> ?hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a list -> 'b list -> 'c option) -> 'a t -> 'b t -> 'c tjoin_all_by ?eq ?hash key1 key2 ~merge la lb is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and, for each key k occurring in at least one of them:
l1 of elements of a that map to kl2 of elements of b that map to kmerge k l1 l2. If merge returns None, the combination of values is discarded, otherwise it returns Some c and c is inserted in the result.val group_join_by : ?eq:('a -> 'a -> bool) -> ?hash:('a -> int) -> ('b -> 'a) -> 'a t -> 'b t -> ('a * 'b list) tgroup_join_by ?eq ?hash key la lb associates to every element x of the first sequence, all the elements y of the second sequence such that eq x (key y). Elements of the first sequences without corresponding values in the second one are mapped to [] precondition: for any x and y, if eq x y then hash x=hash y must hold.
val sublists_of_len : ?last:('a list -> 'a list option) -> ?offset:int -> int -> 'a list -> 'a list listsublists_of_len ?last ?offset n l returns sub-lists of l that have length n. By default, these sub-lists are non overlapping: sublists_of_len 2 [1;2;3;4;5;6] returns [1;2]; [3;4]; [5;6].
Examples:
sublists_of_len 2 [1;2;3;4;5;6] = [[1;2]; [3;4]; [5;6]].sublists_of_len 2 ~offset:3 [1;2;3;4;5;6] = [1;2];[4;5].sublists_of_len 3 ~last:CCOpt.return [1;2;3;4] = [1;2;3];[4].sublists_of_len 2 [1;2;3;4;5] = [[1;2]; [3;4]].the number of elements skipped between two consecutive sub-lists. By default it is n. If offset < n, the sub-lists will overlap; if offset > n, some elements will not appear at all.
if provided and the last group of elements g is such that length g < n, last g is called. If last g = Some g', g' is appended; otherwise g is dropped. If last = CCOpt.return, it will simply keep the last group. By default, last = fun _ -> None, i.e. the last group is dropped if shorter than n.
if offset <= 0 or n <= 0. See CCList.sublists_of_len for more details.
val chunks : int -> 'a list -> 'a list listchunks n l returns consecutives chunks of size at most n from l. Each item of l will occur in exactly one chunk. Only the last chunk might be of length smaller than n. Invariant: (chunks n l |> List.flatten) = l.
val intersperse : 'a -> 'a list -> 'a listintersperse x l inserts the element x between adjacent elements of the list l.
val interleave : 'a list -> 'a list -> 'a listinterleave [x1…xn] [y1…ym] is [x1;y1;x2;y2;…] and finishes with the suffix of the longest list.
val pure : 'a -> 'a tpure x is return x.
val mguard : bool -> unit tmguard c is pure () if c is true, [] otherwise. This is useful to define a list by comprehension, e.g.:
# let square_even xs =
let* x = xs in
let* () = mguard (x mod 2 = 0) in
return @@ x * x;;
diff --git a/dev/containers/CCListLabels/index.html b/dev/containers/CCListLabels/index.html
index e3b6a529..3039168b 100644
--- a/dev/containers/CCListLabels/index.html
+++ b/dev/containers/CCListLabels/index.html
@@ -3,7 +3,7 @@
[[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];;
# cartesian_product [[1;2];[];[4;5;6]] = [];;
# cartesian_product [[1;2];[3];[4];[5];[6]] |> sort =
-[[1;3;4;5;6];[2;3;4;5;6]];;invariant: cartesian_product l = map_product id l.
val map_product_l : f:('a -> 'b list) -> 'a list -> 'b list listmap_product_l ~f l maps each element of l to a list of objects of type 'b using f. We obtain [l1; l2; …; ln] where length l=n and li : 'b list. Then, it returns all the ways of picking exactly one element per li.
val diagonal : 'a t -> ('a * 'a) tdiagonal l returns all pairs of distinct positions of the list l, that is the list of List.nth i l, List.nth j l if i < j.
val partition_filter_either : f:('a -> ('b, 'c) CCEither.t) -> 'a list -> 'b list * 'c listpartition_filter_either ~f l maps f on l and gather results in lists:
f x = Left y, adds y to the first list.f x = Right z, adds z to the second list.val partition_filter_map : f:('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c listpartition_filter_map ~f l maps f on l and gather results in lists:
f x = `Left y, adds y to the first list.f x = `Right z, adds z to the second list.f x = `Drop, ignores x.val partition_map : f:('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c listuse partition_filter_map instead
val group_by : ?hash:('a -> int) -> ?eq:('a -> 'a -> bool) -> 'a t -> 'a list tgroup_by ?hash ?eq l groups equal elements, regardless of their order of appearance. precondition: for any x and y, if eq x y then hash x = hash y must hold.
val join : join_row:('a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c tjoin ~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 join_by : ?eq:('key -> 'key -> bool) -> ?hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c tjoin_by ?eq ?hash key1 key2 ~merge la lb is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and combine values (x,y) from (a,b) with the same key using merge. If merge returns None, the combination of values is discarded. precondition: for any x and y, if eq x y then hash x = hash y must hold.
val join_all_by : ?eq:('key -> 'key -> bool) -> ?hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a list -> 'b list -> 'c option) -> 'a t -> 'b t -> 'c tjoin_all_by ?eq ?hash key1 key2 ~merge la lb is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and, for each key k occurring in at least one of them:
l1 of elements of a that map to kl2 of elements of b that map to kmerge k l1 l2. If merge returns None, the combination of values is discarded, otherwise it returns Some c and c is inserted in the result.val group_join_by : ?eq:('a -> 'a -> bool) -> ?hash:('a -> int) -> ('b -> 'a) -> 'a t -> 'b t -> ('a * 'b list) tgroup_join_by ?eq ?hash key la lb associates to every element x of the first sequence, all the elements y of the second sequence such that eq x (key y). Elements of the first sequences without corresponding values in the second one are mapped to [] precondition: for any x and y, if eq x y then hash x = hash y must hold.
val sublists_of_len : ?last:('a list -> 'a list option) -> ?offset:int -> len:int -> 'a list -> 'a list listsublists_of_len ?last ?offset n l returns sub-lists of l that have length n. By default, these sub-lists are non overlapping: sublists_of_len 2 [1;2;3;4;5;6] returns [1;2]; [3;4]; [5;6].
Examples:
sublists_of_len 2 [1;2;3;4;5;6] = [[1;2]; [3;4]; [5;6]].sublists_of_len 2 ~offset:3 [1;2;3;4;5;6] = [1;2];[4;5].sublists_of_len 3 ~last:CCOpt.return [1;2;3;4] = [1;2;3];[4].sublists_of_len 2 [1;2;3;4;5] = [[1;2]; [3;4]].the number of elements skipped between two consecutive sub-lists. By default it is n. If offset < n, the sub-lists will overlap; if offset > n, some elements will not appear at all.
if provided and the last group of elements g is such that length g < n, last g is called. If last g = Some g', g' is appended; otherwise g is dropped. If last = CCOpt.return, it will simply keep the last group. By default, last = fun _ -> None, i.e. the last group is dropped if shorter than n.
if offset <= 0 or n <= 0. See CCList.sublists_of_len for more details.
val chunks : int -> 'a list -> 'a list listchunks n l returns consecutives chunks of size at most n from l. Each item of l will occur in exactly one chunk. Only the last chunk might be of length smaller than n. Invariant: (chunks n l |> List.flatten) = l.
val intersperse : x:'a -> 'a list -> 'a listintersperse ~x l inserts the element x between adjacent elements of the list l.
val interleave : 'a list -> 'a list -> 'a listinterleave [x1…xn] [y1…ym] is [x1,y1,x2,y2,…] and finishes with the suffix of the longest list.
val pure : 'a -> 'a tpure x is return x.
val mguard : bool -> unit tmguard c is pure () if c is true, [] otherwise. This is useful to define a list by comprehension, e.g.:
# let square_even xs =
+[[1;3;4;5;6];[2;3;4;5;6]];;invariant: cartesian_product l = map_product id l.
val map_product_l : f:('a -> 'b list) -> 'a list -> 'b list listmap_product_l ~f l maps each element of l to a list of objects of type 'b using f. We obtain [l1; l2; …; ln] where length l=n and li : 'b list. Then, it returns all the ways of picking exactly one element per li.
val diagonal : 'a t -> ('a * 'a) tdiagonal l returns all pairs of distinct positions of the list l, that is the list of List.nth i l, List.nth j l if i < j.
val partition_map_either : f:('a -> ('b, 'c) CCEither.t) -> 'a list -> 'b list * 'c listpartition_map_either ~f l maps f on l and gather results in lists:
f x = Left y, adds y to the first list.f x = Right z, adds z to the second list.val partition_filter_map : f:('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c listpartition_filter_map ~f l maps f on l and gather results in lists:
f x = `Left y, adds y to the first list.f x = `Right z, adds z to the second list.f x = `Drop, ignores x.val partition_map : f:('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c listuse partition_filter_map instead
val group_by : ?hash:('a -> int) -> ?eq:('a -> 'a -> bool) -> 'a t -> 'a list tgroup_by ?hash ?eq l groups equal elements, regardless of their order of appearance. precondition: for any x and y, if eq x y then hash x = hash y must hold.
val join : join_row:('a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c tjoin ~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 join_by : ?eq:('key -> 'key -> bool) -> ?hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c tjoin_by ?eq ?hash key1 key2 ~merge la lb is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and combine values (x,y) from (a,b) with the same key using merge. If merge returns None, the combination of values is discarded. precondition: for any x and y, if eq x y then hash x = hash y must hold.
val join_all_by : ?eq:('key -> 'key -> bool) -> ?hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a list -> 'b list -> 'c option) -> 'a t -> 'b t -> 'c tjoin_all_by ?eq ?hash key1 key2 ~merge la lb is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and, for each key k occurring in at least one of them:
l1 of elements of a that map to kl2 of elements of b that map to kmerge k l1 l2. If merge returns None, the combination of values is discarded, otherwise it returns Some c and c is inserted in the result.val group_join_by : ?eq:('a -> 'a -> bool) -> ?hash:('a -> int) -> ('b -> 'a) -> 'a t -> 'b t -> ('a * 'b list) tgroup_join_by ?eq ?hash key la lb associates to every element x of the first sequence, all the elements y of the second sequence such that eq x (key y). Elements of the first sequences without corresponding values in the second one are mapped to [] precondition: for any x and y, if eq x y then hash x = hash y must hold.
val sublists_of_len : ?last:('a list -> 'a list option) -> ?offset:int -> len:int -> 'a list -> 'a list listsublists_of_len ?last ?offset n l returns sub-lists of l that have length n. By default, these sub-lists are non overlapping: sublists_of_len 2 [1;2;3;4;5;6] returns [1;2]; [3;4]; [5;6].
Examples:
sublists_of_len 2 [1;2;3;4;5;6] = [[1;2]; [3;4]; [5;6]].sublists_of_len 2 ~offset:3 [1;2;3;4;5;6] = [1;2];[4;5].sublists_of_len 3 ~last:CCOpt.return [1;2;3;4] = [1;2;3];[4].sublists_of_len 2 [1;2;3;4;5] = [[1;2]; [3;4]].the number of elements skipped between two consecutive sub-lists. By default it is n. If offset < n, the sub-lists will overlap; if offset > n, some elements will not appear at all.
if provided and the last group of elements g is such that length g < n, last g is called. If last g = Some g', g' is appended; otherwise g is dropped. If last = CCOpt.return, it will simply keep the last group. By default, last = fun _ -> None, i.e. the last group is dropped if shorter than n.
if offset <= 0 or n <= 0. See CCList.sublists_of_len for more details.
val chunks : int -> 'a list -> 'a list listchunks n l returns consecutives chunks of size at most n from l. Each item of l will occur in exactly one chunk. Only the last chunk might be of length smaller than n. Invariant: (chunks n l |> List.flatten) = l.
val intersperse : x:'a -> 'a list -> 'a listintersperse ~x l inserts the element x between adjacent elements of the list l.
val interleave : 'a list -> 'a list -> 'a listinterleave [x1…xn] [y1…ym] is [x1,y1,x2,y2,…] and finishes with the suffix of the longest list.
val pure : 'a -> 'a tpure x is return x.
val mguard : bool -> unit tmguard c is pure () if c is true, [] otherwise. This is useful to define a list by comprehension, e.g.:
# let square_even xs =
let* x = xs in
let* () = mguard (x mod 2 = 0) in
return @@ x * x;;