day 3, add [un]curry and swap to utils

This commit is contained in:
Vladan Popovic 2022-12-03 17:01:56 +01:00
parent efde27f8c8
commit 883d16a3a3
4 changed files with 366 additions and 0 deletions

View file

@ -9,3 +9,18 @@ let read_file name =
| None -> close_in ic; acc in
aux []
module CS = Set.Make(Char);;
let set_of_string str =
let rec aux s i st =
if i < 0 then st
else aux s (i - 1) (CS.add s.[i] st) in
aux str ((String.length str) - 1) CS.empty
let map_pair f (a, b) = (f a, f b)
let curry f x y = f (x, y)
let uncurry f (x, y) = f x y
let uncurry3 f (x, y, z) = f x y z
let swap x y = y x