From 36790cf3edb7f0bd0f6b13dcdb4e2966a336f318 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 5 Dec 2023 12:19:15 -0500 Subject: [PATCH] bugfix --- src/core/CCList.ml | 2 +- tests/core/t_list.ml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/CCList.ml b/src/core/CCList.ml index d5d791ac..0d5d866f 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -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 = diff --git a/tests/core/t_list.ml b/tests/core/t_list.ml index b32aef65..05de8854 100644 --- a/tests/core/t_list.ml +++ b/tests/core/t_list.ml @@ -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 ->