Compare commits

..

No commits in common. "a525d4902c9fb71e6acd84ee1f2ab8e1f3eefb10" and "fc69ce4c919cdd04fb5041410fd61d5a3f742702" have entirely different histories.

8 changed files with 33 additions and 28 deletions

View file

@ -11,7 +11,14 @@ jobs:
steps:
- uses: actions/checkout@main
- uses: ocaml/setup-ocaml@v3
- name: Cache opam
id: cache-opam
uses: actions/cache@v2
with:
path: ~/.opam
key: opam-ubuntu-latest-4.12.0
- uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: '4.14.x'
allow-prerelease-opam: true

View file

@ -21,7 +21,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: ocaml/setup-ocaml@v3
- uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
allow-prerelease-opam: true

View file

@ -1,4 +1,4 @@
version = 0.26.2
version = 0.24.1
profile=conventional
margin=80
if-then-else=k-r

View file

@ -1,10 +1,4 @@
# 1.9
- Switch exceptions used for control flow from global to local
- Update Iter.ml to use mutable fields instead of refs (#44)
# 1.8
- add `Iter.map_while`

View file

@ -1,6 +1,6 @@
opam-version: "2.0"
name: "iter"
version: "1.9"
version: "1.8"
authors: ["Simon Cruanes" "Gabriel Radanne"]
maintainer: "simon.cruanes.2007@m4x.org"
license: "BSD-2-clause"

View file

@ -330,8 +330,9 @@ let sort ?(cmp = Stdlib.compare) seq =
let l = List.fast_sort cmp l in
fun k -> List.iter k l
exception Exit_sorted
let sorted ?(cmp = Stdlib.compare) seq =
let exception Exit_sorted in
let prev = ref None in
try
seq (fun x ->
@ -555,8 +556,9 @@ let diff (type a) ?(eq = ( = )) ?(hash = Hashtbl.hash) c1 c2 =
c2 (fun x -> Tbl.replace tbl x ());
fun yield -> c1 (fun x -> if not (Tbl.mem tbl x) then yield x)
exception Subset_exit
let subset (type a) ?(eq = ( = )) ?(hash = Hashtbl.hash) c1 c2 =
let exception Subset_exit in
let module Tbl = Hashtbl.Make (struct
type t = a
@ -628,8 +630,9 @@ let sumf seq : float =
sum := t);
!sum
exception ExitHead
let head seq =
let exception ExitHead in
let r = ref None in
try
seq (fun x ->
@ -643,8 +646,9 @@ let head_exn seq =
| None -> invalid_arg "Iter.head_exn"
| Some x -> x
exception ExitTake
let take n seq k =
let exception ExitTake in
let count = ref 0 in
try
seq (fun x ->
@ -653,8 +657,9 @@ let take n seq k =
k x)
with ExitTake -> ()
exception ExitTakeWhile
let take_while p seq k =
let exception ExitTakeWhile in
try
seq (fun x ->
if p x then
@ -663,6 +668,8 @@ let take_while p seq k =
raise_notrace ExitTakeWhile)
with ExitTakeWhile -> ()
exception ExitFoldWhile
let map_while f seq k =
let exception ExitMapWhile in
let consume x =
@ -676,7 +683,6 @@ let map_while f seq k =
try seq consume with ExitMapWhile -> ()
let fold_while f s seq =
let exception ExitFoldWhile in
let state = ref s in
let consume x =
let acc, cont = f !state x in
@ -715,16 +721,18 @@ let rev seq =
let l = MList.of_iter seq in
fun k -> MList.iter_rev k l
exception ExitForall
let for_all p seq =
let exception ExitForall in
try
seq (fun x -> if not (p x) then raise_notrace ExitForall);
true
with ExitForall -> false
exception ExitExists
(** Exists there some element satisfying the predicate? *)
let exists p seq =
let exception ExitExists in
try
seq (fun x -> if p x then raise_notrace ExitExists);
false
@ -732,8 +740,9 @@ let exists p seq =
let mem ?(eq = ( = )) x seq = exists (eq x) seq
exception ExitFind
let find_map f seq =
let exception ExitFind in
let r = ref None in
(try
seq (fun x ->
@ -748,7 +757,6 @@ let find_map f seq =
let find = find_map
let find_mapi f seq =
let exception ExitFind in
let i = ref 0 in
let r = ref None in
(try
@ -782,8 +790,9 @@ let[@inline] length seq =
seq (fun _ -> incr r);
!r
exception ExitIsEmpty
let is_empty seq =
let exception ExitIsEmpty in
try
seq (fun _ -> raise_notrace ExitIsEmpty);
true
@ -1031,14 +1040,9 @@ module Map = struct
let of_iter_ seq = fold (fun m (k, v) -> M.add k v m) M.empty seq
let keys m = from_iter (fun k -> M.iter (fun x _ -> k x) m)
let values m = from_iter (fun k -> M.iter (fun _ y -> k y) m)
[@@@ocaml.warning "-32"]
let of_list l = of_iter_ (of_list l)
let to_list x = to_list (to_iter_ x)
[@@@ocaml.warning "+32"]
include M
let to_iter = to_iter_

View file

@ -22,4 +22,4 @@ let mmap filename yield =
with e ->
Unix.close fd;
raise e
[@@ocaml.warning "-3"]
[@@ocaml.warning "-3"]

View file

@ -3,7 +3,7 @@
(public_name iter)
(wrapped false)
(modules Iter IterLabels)
(flags :standard -w +a-4 -warn-error -a+8 -nolabels))
(flags :standard -w +a -warn-error -a+8 -nolabels))
(env
(_