Skip to content

Instantly share code, notes, and snippets.

@thedeemon
Last active August 3, 2023 10:35
Show Gist options
  • Save thedeemon/9681e57fc0787c410feef35551563aa0 to your computer and use it in GitHub Desktop.
Save thedeemon/9681e57fc0787c410feef35551563aa0 to your computer and use it in GitHub Desktop.
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