mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -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
|
match f seed with
|
||||||
| None -> k []
|
| None -> k []
|
||||||
| Some (v, next) ->
|
| Some (v, next) ->
|
||||||
let k' tl = v :: tl in
|
let k' tl = v :: k tl in
|
||||||
unfold_kont f next k'
|
unfold_kont f next k'
|
||||||
|
|
||||||
let[@inline] unfold f seed =
|
let[@inline] unfold f seed =
|
||||||
|
|
|
||||||
|
|
@ -131,17 +131,18 @@ q
|
||||||
= (List.rev l, flat_map (fun x -> [ x; x + 10 ]) l))
|
= (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 =
|
let f x =
|
||||||
if x <= 5 then
|
if x <= 5 then
|
||||||
Some (2 * x, x + 1)
|
Some (2 * x, x + 1)
|
||||||
else
|
else
|
||||||
None
|
None
|
||||||
in
|
in
|
||||||
unfold f 0 = [ 0; 2; 4; 6; 8; 10 ]
|
unfold f 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
t @@ fun () ->
|
t ~name:"unfold2" @@ fun () ->
|
||||||
let l =
|
let l =
|
||||||
unfold
|
unfold
|
||||||
(fun n ->
|
(fun n ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue