]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7489) Added replicate function to Prelude 83/983/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 18 Sep 2017 11:23:53 +0000 (14:23 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 18 Sep 2017 11:23:53 +0000 (14:23 +0300)
Also removed a debug print from OpenDeclaration.

Change-Id: I9fff24e82183dfee46354800f277ab1987bb5d09

bundles/org.simantics.scl.runtime/scl/Prelude.scl
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenDeclaration.java

index f0eca0eb26dc78141f4a4f204f9f46ce14948c2c..83d84ccf2da505c6590b404c23c93a484fb98ad2 100644 (file)
@@ -1065,6 +1065,15 @@ mapEither f list = runProc do
         Right v -> addArrayList r v)
     (Java.unsafeCoerce l, Java.unsafeCoerce r)
 
+"`replicate n v` returns a list of length `n` such that each element is a copy of `v`."
+@inline
+replicate :: Integer -> a -> [a]
+replicate n v = build (\empty cons ->
+    let aux 0 l = l
+        aux i l = aux (i-1) (cons l v)
+    in aux n empty 
+    )
+
 /// FunctorM ///
 
 class (Functor f) => FunctorM f where
index 378840397759e1fbdbdc3714b2c3c930c01fa32b..878d8e24fcf0d86821db1d4b85af70fa88480e71 100644 (file)
@@ -107,7 +107,7 @@ public class OpenDeclaration extends AbstractHandler {
             SCLTextEditorEnvironment editorEnvironment = moduleEditor.getSCLTextEditorEnvironment();
             editorEnvironment.updateEnvironment(moduleEditor.getDocument());
             SCLValue value = editorEnvironment.getValue(identifierAtCaret);
-            System.out.println("identifierAtCaret = " + identifierAtCaret + " [" + Locations.beginOf(value.definitionLocation) + ", " + Locations.endOf(value.definitionLocation) + "]");
+            //System.out.println("identifierAtCaret = " + identifierAtCaret + " [" + Locations.beginOf(value.definitionLocation) + ", " + Locations.endOf(value.definitionLocation) + "]");
             if(value != null)
                 OpenSCLDefinition.openDefinition(value);
         }