]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/scl/SetUtils.scl
(refs #7384) Added SetUtils module with Set.fromList and Set.toList
[simantics/platform.git] / 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 (file)
index 0000000..00fa752
--- /dev/null
@@ -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