summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-02-05 12:44:20 -0800
committerOri Bernstein <ori@eigenstate.org>2016-02-05 12:44:20 -0800
commit3c1277e37fbaea87d770d4a64a5029c4a693bb63 (patch)
treef17a4bd4f64c9b67820c66a51ae731852fa454e0
parentd515158d85a5361cd9127f13424e4242226ab9b0 (diff)
downloadmc-3c1277e37fbaea87d770d4a64a5029c4a693bb63.tar.gz
Add missing file.
-rw-r--r--lib/std/striter.myr31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/std/striter.myr b/lib/std/striter.myr
new file mode 100644
index 0000000..6527b8a
--- /dev/null
+++ b/lib/std/striter.myr
@@ -0,0 +1,31 @@
+use "die"
+use "types"
+use "utf"
+
+pkg std =
+ type chariter = struct
+ rest : byte[:]
+ ;;
+
+ impl iterable chariter -> char
+
+ const bychar : (str : byte[:] -> chariter)
+;;
+
+impl iterable chariter -> char =
+ __iternext__ = {ci, c
+ if ci.rest.len == 0
+ -> false
+ ;;
+ (c#, ci.rest) = strstep(ci.rest)
+ -> true
+ }
+
+ __iterfin__ = {ci, c
+ }
+;;
+
+const bychar = {str
+ -> [.rest = str]
+}
+