]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/scl/Iterator.scl
Implemented many type class instances for Set.T
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / Iterator.scl
index 19e51a0d5836d23cb2447daabdb1d2093e6d093a..b98e14f423aaccb9252883be3d95c569833ce8bf 100644 (file)
@@ -1,3 +1,5 @@
+import "JavaBuiltin" as Java
+
 importJava "java.util.Iterator" where
     data T a
     
@@ -16,6 +18,17 @@ iter f it = loop ()
             loop ()
         else ()
 
+@inline
+iterI :: (Integer -> a -> <e> b) -> T a -> <Proc,e> ()
+iterI f it = loop 0
+  where
+    loop i = 
+        if hasNext it
+        then do
+            f i (next it)
+            loop (Java.iadd i 1)
+        else ()
+        
 @inline
 iterB :: (a -> <e> Boolean) -> T a -> <Proc,e> Boolean
 iterB f it = loop ()