From 903876eb2266ac276bdc78e951a6839912921f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abigail=20Magalh=C3=A3es?= Date: Sat, 28 Mar 2020 17:23:20 -0300 Subject: [PATCH] UGhghrhrh --- lib/data/set.ml | 3 +++ lib/prelude.ml | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/data/set.ml b/lib/data/set.ml index 8c915c64e..d192765f2 100644 --- a/lib/data/set.ml +++ b/lib/data/set.ml @@ -24,6 +24,9 @@ let singleton x = S (T.singleton x) (** Construct a 'set' from the elements of a 'list' *) let from_list (xs : list _) = S (T.from_foldable xs) +(** Construct a 'list' from the elements of a 'set', in ascending order *) +let to_list (xs : t _) = T.inorder_fold (::) [] xs + (** Insert an element into a 'set'. *) let insert x (S tree) = S (T.insert x tree) diff --git a/lib/prelude.ml b/lib/prelude.ml index 3dd4cb2fb..b797a27fe 100644 --- a/lib/prelude.ml +++ b/lib/prelude.ml @@ -32,3 +32,4 @@ let print = Io.print let flip f x y = f y x let x |> f = f x let f # g = fun x -> f (g x) +let map f x = f <$> x