From af07e3fba55ef98aabd54057c6e3433734b81111 Mon Sep 17 00:00:00 2001 From: mryouse Date: Thu, 1 Jun 2023 20:17:37 -0400 Subject: split concat/append into 2 ops --- chunk.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'chunk.d') diff --git a/chunk.d b/chunk.d index e24e3ab..47a2d7e 100644 --- a/chunk.d +++ b/chunk.d @@ -46,7 +46,6 @@ abstract class Seq { abstract Value first(); abstract Seq rest(); abstract int length(); - abstract Seq concat(Seq seq); abstract bool isIn(Value val); } @@ -75,7 +74,7 @@ class String : Seq { return to!int(str.length); } - override Seq concat(Seq seq) { + Seq concat(Seq seq) { if (seq.type != SeqType.STRING) { // how do i throw an error here? writeln("must concat strings to strings!"); @@ -138,13 +137,13 @@ class List : Seq { return to!int(this.inner.length); } - override Seq concat(Seq seq) { + Seq append(Value val) { int length = to!int(this.inner.length); List ret = new List(length + 1); for (int i = 0; i < length; i++) { ret.addItemAtIndex(this.inner[i], i); } - ret.addItemAtIndex(makeSeqValue(seq), length); + ret.addItemAtIndex(val, length); return ret; } @@ -189,6 +188,7 @@ enum OpCode { // SEQUENCES OP_CONCAT, // No? + OP_APPEND, OP_FIRST, // No? OP_LENGTH, OP_MEMBER, -- cgit v1.2.3