diff options
| author | mryouse | 2023-05-26 01:36:49 +0000 |
|---|---|---|
| committer | mryouse | 2023-05-26 01:36:49 +0000 |
| commit | 6b7b9d96fb26ba9d4616d2b839098b7c75f39c3f (patch) | |
| tree | f8fbfc86d0ff65cc55d30e30361664c8a10998dd /chunk.d | |
| parent | 9b97f36c3d57459c4de1e7da52e882c9d88142ae (diff) | |
strings as seqs
Diffstat (limited to 'chunk.d')
| -rw-r--r-- | chunk.d | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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; |
