Last active
August 3, 2023 10:35
-
-
Save thedeemon/9681e57fc0787c410feef35551563aa0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Ible[e] { | |
case MkIter(Int32, Int32 -> e) | |
} | |
instance Iterable[Ible] { | |
pub def iterator(rc: Region[r], s: Ible[a]): Iterator[a, r, r] \ r = | |
let Ible.MkIter(n, f) = s; | |
Iterator.range(rc, 0, n) |> Iterator.map(f) | |
} | |
def ible(s:String):Ible[Char] = | |
Ible.MkIter(String.length(s), i -> String.charAt(i, s)) | |
def main() : Unit \ IO = | |
let s = "abc"; | |
foreach(c <- ible(s)) | |
println(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment