From f6eb89f397489b840e674a460b4d6f0c7847666c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Wed, 26 Jul 2017 10:20:08 +0300 Subject: [PATCH] (refs #7384) Added SetUtils module with Set.fromList and Set.toList Change-Id: I25e9808539a2093af62a686a9c3dd1332d3d7abf --- bundles/org.simantics.scl.runtime/scl/SetUtils.scl | 13 +++++++++++++ .../scl/StandardLibrary.scl | 1 + 2 files changed, 14 insertions(+) create mode 100644 bundles/org.simantics.scl.runtime/scl/SetUtils.scl diff --git a/bundles/org.simantics.scl.runtime/scl/SetUtils.scl b/bundles/org.simantics.scl.runtime/scl/SetUtils.scl new file mode 100644 index 000000000..00fa75215 --- /dev/null +++ b/bundles/org.simantics.scl.runtime/scl/SetUtils.scl @@ -0,0 +1,13 @@ +import "Prelude" +import "Set" as Set +import "MSet" as MSet +import "MList" as MList + +fromList :: [a] -> Set.T a +fromList l = runProc (MSet.freeze $ MSet.fromList l) + +toList :: Set.T a -> [a] +toList s = runProc do + result = MList.createC (Set.size s) + Set.iter (MList.add result) s + MList.freeze result \ No newline at end of file diff --git a/bundles/org.simantics.scl.runtime/scl/StandardLibrary.scl b/bundles/org.simantics.scl.runtime/scl/StandardLibrary.scl index 122fcd02b..7234b70be 100644 --- a/bundles/org.simantics.scl.runtime/scl/StandardLibrary.scl +++ b/bundles/org.simantics.scl.runtime/scl/StandardLibrary.scl @@ -10,6 +10,7 @@ include "Lazy" as Lazy include "File" as File include "Serialization" as Serialization include "Set" as Set +include "SetUtils" as Set //include "Map" as Map include "MMap" as MMap include "MSet" as MSet -- 2.47.1