mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
bugfix
This commit is contained in:
parent
7fcf26963b
commit
36790cf3ed
2 changed files with 5 additions and 4 deletions
|
|
@ -313,7 +313,7 @@ let rec unfold_kont f seed k =
|
|||
match f seed with
|
||||
| None -> k []
|
||||
| Some (v, next) ->
|
||||
let k' tl = v :: tl in
|
||||
let k' tl = v :: k tl in
|
||||
unfold_kont f next k'
|
||||
|
||||
let[@inline] unfold f seed =
|
||||
|
|
|
|||
|
|
@ -131,17 +131,18 @@ q
|
|||
= (List.rev l, flat_map (fun x -> [ x; x + 10 ]) l))
|
||||
;;
|
||||
|
||||
t @@ fun () ->
|
||||
eq ~printer:Q.Print.(list int) ~name:"unfold1" [ 0; 2; 4; 6; 8; 10 ]
|
||||
@@
|
||||
let f x =
|
||||
if x <= 5 then
|
||||
Some (2 * x, x + 1)
|
||||
else
|
||||
None
|
||||
in
|
||||
unfold f 0 = [ 0; 2; 4; 6; 8; 10 ]
|
||||
unfold f 0
|
||||
;;
|
||||
|
||||
t @@ fun () ->
|
||||
t ~name:"unfold2" @@ fun () ->
|
||||
let l =
|
||||
unfold
|
||||
(fun n ->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue