prepare for 0.10

This commit is contained in:
Simon Cruanes 2017-02-17 17:25:24 +01:00
parent d68c80f51d
commit 76191b8577
6 changed files with 24 additions and 15 deletions

View file

@ -1,5 +1,13 @@
# Changelog # Changelog
## 0.10
- add `{union,inter,diff,subset}`
- add `{join_by,join_all_by,group_join_by}`
- add `find_map{,i}` as better alias to existing functions
- add `{max_exn,min_exn}`
- add `count`
- add `doc` and `test` to opam
## 0.9 ## 0.9

View file

@ -169,6 +169,7 @@ enumerating the ways we can insert an element in a list.
[source,OCaml] [source,OCaml]
---- ----
# open Sequence.Infix;;
# module S = Sequence ;; # module S = Sequence ;;
# let rec insert x l = match l with # let rec insert x l = match l with
| [] -> S.return [x] | [] -> S.return [x]

2
_oasis
View file

@ -1,6 +1,6 @@
OASISFormat: 0.4 OASISFormat: 0.4
Name: sequence Name: sequence
Version: 0.9 Version: 0.10
Homepage: https://github.com/c-cube/sequence Homepage: https://github.com/c-cube/sequence
Authors: Simon Cruanes Authors: Simon Cruanes
License: BSD-2-clause License: BSD-2-clause

2
opam
View file

@ -1,6 +1,6 @@
opam-version: "1.2" opam-version: "1.2"
name: "sequence" name: "sequence"
version: "0.9" version: "0.10"
author: "Simon Cruanes" author: "Simon Cruanes"
maintainer: "simon.cruanes@inria.fr" maintainer: "simon.cruanes@inria.fr"
license: "BSD-2-clauses" license: "BSD-2-clauses"

View file

@ -149,7 +149,7 @@ val find : ('a -> 'b option) -> 'a t -> 'b option
val find_map : ('a -> 'b option) -> 'a t -> 'b option val find_map : ('a -> 'b option) -> 'a t -> 'b option
(** Alias to {!find} (** Alias to {!find}
@since NEXT_RELEASE *) @since 0.10 *)
val findi : (int -> 'a -> 'b option) -> 'a t -> 'b option val findi : (int -> 'a -> 'b option) -> 'a t -> 'b option
(** Indexed version of {!find} (** Indexed version of {!find}
@ -157,7 +157,7 @@ val findi : (int -> 'a -> 'b option) -> 'a t -> 'b option
val find_mapi : (int -> 'a -> 'b option) -> 'a t -> 'b option val find_mapi : (int -> 'a -> 'b option) -> 'a t -> 'b option
(** Alias to {!findi} (** Alias to {!findi}
@since NEXT_RELEASE *) @since 0.10 *)
val find_pred : ('a -> bool) -> 'a t -> 'a option val find_pred : ('a -> bool) -> 'a t -> 'a option
(** [find_pred p l] finds the first element of [l] that satisfies [p], (** [find_pred p l] finds the first element of [l] that satisfies [p],
@ -256,7 +256,7 @@ val count : ?hash:('a -> int) -> ?eq:('a -> 'a -> bool) ->
'a t -> ('a * int) t 'a t -> ('a * int) t
(** Map each distinct element to its number of occurrences in the whole seq. (** Map each distinct element to its number of occurrences in the whole seq.
Similar to [group_by seq |> map (fun l->List.hd l, List.length l)] Similar to [group_by seq |> map (fun l->List.hd l, List.length l)]
@since NEXT_RELEASE *) @since 0.10 *)
val uniq : ?eq:('a -> 'a -> bool) -> 'a t -> 'a t val uniq : ?eq:('a -> 'a -> bool) -> 'a t -> 'a t
(** Remove consecutive duplicate elements. Basically this is (** Remove consecutive duplicate elements. Basically this is
@ -300,7 +300,7 @@ val join_by : ?eq:'key equal -> ?hash:'key hash ->
values [(x,y)] from [(a,b)] with the same [key] values [(x,y)] from [(a,b)] with the same [key]
using [merge]. If [merge] returns [None], the combination using [merge]. If [merge] returns [None], the combination
of values is discarded. of values is discarded.
@since NEXT_RELEASE *) @since 0.10 *)
val join_all_by : ?eq:'key equal -> ?hash:'key hash -> val join_all_by : ?eq:'key equal -> ?hash:'key hash ->
('a -> 'key) -> ('b -> 'key) -> ('a -> 'key) -> ('b -> 'key) ->
@ -317,7 +317,7 @@ val join_all_by : ?eq:'key equal -> ?hash:'key hash ->
- call [merge k l1 l2]. If [merge] returns [None], the combination - call [merge k l1 l2]. If [merge] returns [None], the combination
of values is discarded, otherwise it returns [Some c] of values is discarded, otherwise it returns [Some c]
and [c] is inserted in the result. and [c] is inserted in the result.
@since NEXT_RELEASE *) @since 0.10 *)
val group_join_by : ?eq:'a equal -> ?hash:'a hash -> val group_join_by : ?eq:'a equal -> ?hash:'a hash ->
('b -> 'a) -> ('b -> 'a) ->
@ -329,14 +329,14 @@ val group_join_by : ?eq:'a equal -> ?hash:'a hash ->
sequence such that [eq x (key y)]. Elements of the first sequence such that [eq x (key y)]. Elements of the first
sequences without corresponding values in the second one sequences without corresponding values in the second one
are mapped to [[]] are mapped to [[]]
@since NEXT_RELEASE *) @since 0.10 *)
val inter : val inter :
?eq:'a equal -> ?hash:'a hash -> ?eq:'a equal -> ?hash:'a hash ->
'a t -> 'a t -> 'a t 'a t -> 'a t -> 'a t
(** Intersection of two collections. Each element will occur at most once (** Intersection of two collections. Each element will occur at most once
in the result. Eager. in the result. Eager.
@since NEXT_RELEASE *) @since 0.10 *)
(*$= (*$=
[2;4;5;6] (inter (1--6) (cons 2 (4--10)) |> sort |> to_list) [2;4;5;6] (inter (1--6) (cons 2 (4--10)) |> sort |> to_list)
@ -348,7 +348,7 @@ val union :
'a t -> 'a t -> 'a t 'a t -> 'a t -> 'a t
(** Union of two collections. Each element will occur at most once (** Union of two collections. Each element will occur at most once
in the result. Eager. in the result. Eager.
@since NEXT_RELEASE *) @since 0.10 *)
(*$= (*$=
[2;4;5;6] (union (4--6) (cons 2 (4--5)) |> sort |> to_list) [2;4;5;6] (union (4--6) (cons 2 (4--5)) |> sort |> to_list)
@ -358,7 +358,7 @@ val diff :
?eq:'a equal -> ?hash:'a hash -> ?eq:'a equal -> ?hash:'a hash ->
'a t -> 'a t -> 'a t 'a t -> 'a t -> 'a t
(** Set difference. Eager. (** Set difference. Eager.
@since NEXT_RELEASE *) @since 0.10 *)
(*$= (*$=
[1;2;8;9;10] (diff (1--10) (3--7) |> to_list) [1;2;8;9;10] (diff (1--10) (3--7) |> to_list)
@ -368,7 +368,7 @@ val subset :
?eq:'a equal -> ?hash:'a hash -> ?eq:'a equal -> ?hash:'a hash ->
'a t -> 'a t -> bool 'a t -> 'a t -> bool
(** [subset a b] returns [true] if all elements of [a] belong to [b]. Eager. (** [subset a b] returns [true] if all elements of [a] belong to [b]. Eager.
@since NEXT_RELEASE *) @since 0.10 *)
(*$T (*$T
subset (2 -- 4) (1 -- 4) subset (2 -- 4) (1 -- 4)
@ -391,7 +391,7 @@ val max : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option
val max_exn : ?lt:('a -> 'a -> bool) -> 'a t -> 'a val max_exn : ?lt:('a -> 'a -> bool) -> 'a t -> 'a
(** Unsafe version of {!max} (** Unsafe version of {!max}
@raise Not_found if the sequence is empty @raise Not_found if the sequence is empty
@since NEXT_RELEASE *) @since 0.10 *)
val min : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option val min : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option
(** Min element of the sequence, using the given comparison function. (** Min element of the sequence, using the given comparison function.
@ -400,7 +400,7 @@ val min : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option
val min_exn : ?lt:('a -> 'a -> bool) -> 'a t -> 'a val min_exn : ?lt:('a -> 'a -> bool) -> 'a t -> 'a
(** Unsafe version of {!min} (** Unsafe version of {!min}
@raise Not_found if the sequence is empty @raise Not_found if the sequence is empty
@since NEXT_RELEASE *) @since 0.10 *)
val head : 'a t -> 'a option val head : 'a t -> 'a option
(** First element, if any, otherwise [None] (** First element, if any, otherwise [None]

View file

@ -216,7 +216,7 @@ val count : ?hash:('a -> int) -> ?eq:('a -> 'a -> bool) ->
'a t -> ('a * int) t 'a t -> ('a * int) t
(** Map each distinct element to its number of occurrences in the whole seq. (** Map each distinct element to its number of occurrences in the whole seq.
Similar to [group_by seq |> map (fun l->List.hd l, List.length l)] Similar to [group_by seq |> map (fun l->List.hd l, List.length l)]
@since NEXT_RELEASE *) @since 0.10 *)
val uniq : ?eq:('a -> 'a -> bool) -> 'a t -> 'a t val uniq : ?eq:('a -> 'a -> bool) -> 'a t -> 'a t
(** Remove consecutive duplicate elements. Basically this is (** Remove consecutive duplicate elements. Basically this is