aboutsummaryrefslogtreecommitdiff
path: root/chunk.d
diff options
context:
space:
mode:
authormryouse2023-05-26 01:36:49 +0000
committermryouse2023-05-26 01:36:49 +0000
commit6b7b9d96fb26ba9d4616d2b839098b7c75f39c3f (patch)
treef8fbfc86d0ff65cc55d30e30361664c8a10998dd /chunk.d
parent9b97f36c3d57459c4de1e7da52e882c9d88142ae (diff)
strings as seqs
Diffstat (limited to 'chunk.d')
-rw-r--r--chunk.d28
1 files changed, 28 insertions, 0 deletions
diff --git a/chunk.d b/chunk.d
index 47d3c73..08ba003 100644
--- a/chunk.d
+++ b/chunk.d
@@ -48,6 +48,34 @@ abstract class Seq {
abstract int length();
}
+class String : Seq {
+ string str;
+
+ this(Value value) {
+ this.str = value.as.str;
+ }
+
+ this(string str) {
+ this.str = str;
+ }
+
+ override Value first() {
+ return makeStringValue(to!string(this.str[0]));
+ }
+
+ override Seq rest() {
+ return new String(this.str[1..$]);
+ }
+
+ override int length() {
+ return to!int(str.length);
+ }
+
+ override string toString() {
+ return format("\"%s\"", this.str);
+ }
+}
+
class List : Seq {
Value[] inner;