X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fscl%2FIterator.scl;h=b98e14f423aaccb9252883be3d95c569833ce8bf;hb=33b30297f751e06e9abac260d31313e2f833fedc;hp=19e51a0d5836d23cb2447daabdb1d2093e6d093a;hpb=fad36d463b75c3a9944d875fc627c3533f6da74d;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.runtime/scl/Iterator.scl b/bundles/org.simantics.scl.runtime/scl/Iterator.scl index 19e51a0d5..b98e14f42 100644 --- a/bundles/org.simantics.scl.runtime/scl/Iterator.scl +++ b/bundles/org.simantics.scl.runtime/scl/Iterator.scl @@ -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 -> b) -> T a -> () +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 -> Boolean) -> T a -> Boolean iterB f it = loop ()