From 57da947edf6bc57a3f1dc53263d7e8a9d945599f Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Tue, 6 Dec 2022 04:20:12 +0100 Subject: [PATCH] add range (like python) and id helper functions --- lib/utils.ml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/utils.ml b/lib/utils.ml index 5722ce1..5918ea9 100644 --- a/lib/utils.ml +++ b/lib/utils.ml @@ -25,3 +25,11 @@ let uncurry3 f (x, y, z) = f x y z let swap x y = y x let pair_of_list l = (List.hd l, List.tl l |> List.hd) + +let range x = + let rec aux n res = + if n = 0 then res + else aux (n - 1) (n :: res) in + aux x [] + +let id x = x