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?p=simantics%2Fplatform.git;a=commitdiff_plain;h=f6eb89f397489b840e674a460b4d6f0c7847666c;hp=97872f96afc18f4cd5b959d869fed80cd92f6aa1 (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