From: Hannu Niemistö Date: Wed, 26 Jul 2017 11:16:58 +0000 (+0300) Subject: Merge "(refs #7384) Added SetUtils module with Set.fromList and Set.toList" X-Git-Tag: v1.31.0~264^2~26 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=84b52b5e5dc00fd0ddfab398e420b56b379ee867;hp=560d8aa2e37cb6b0249aec6d7e96e67d5a64c59f Merge "(refs #7384) Added SetUtils module with Set.fromList and Set.toList" --- 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