(refs #7384) Added SetUtils module with Set.fromList and Set.toList 66/766/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 26 Jul 2017 07:20:08 +0000 (10:20 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 26 Jul 2017 07:20:08 +0000 (10:20 +0300)
Change-Id: I25e9808539a2093af62a686a9c3dd1332d3d7abf

bundles/org.simantics.scl.runtime/scl/SetUtils.scl [new file with mode: 0644]
bundles/org.simantics.scl.runtime/scl/StandardLibrary.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
index 122fcd02b99dc8e943f72c08776c955890e45454..7234b70be861c80806d752140cb575f5453b153c 100644 (file)
@@ -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