From: Hannu Niemistö Date: Wed, 26 Jul 2017 07:20:08 +0000 (+0300) Subject: (refs #7384) Added SetUtils module with Set.fromList and Set.toList X-Git-Tag: v1.31.0~264^2~26^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F66%2F766%2F1;p=simantics%2Fplatform.git (refs #7384) Added SetUtils module with Set.fromList and Set.toList Change-Id: I25e9808539a2093af62a686a9c3dd1332d3d7abf --- 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