diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-16 03:25:45 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-16 03:25:45 +0300 |
commit | 4daf7b149622a16a2271630a19f0833702477a86 (patch) | |
tree | bc09cbc387ab4e551557f94b67c72e7095a07658 /src/sexp/step.rs | |
parent | fad9bf51e9ecd48473046a5e7bb9b5005893ae89 (diff) | |
download | myslip-4daf7b149622a16a2271630a19f0833702477a86.tar.gz myslip-4daf7b149622a16a2271630a19f0833702477a86.zip |
feat: vector concatenation
Diffstat (limited to 'src/sexp/step.rs')
-rw-r--r-- | src/sexp/step.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/sexp/step.rs b/src/sexp/step.rs index 9077401..59b201c 100644 --- a/src/sexp/step.rs +++ b/src/sexp/step.rs @@ -441,6 +441,27 @@ impl SExp { }, + // Concatenation + SCons(op, l) if *op == Atom(Concat) => { + let ls = l.parts(); + let firstvec = ls.get(0).unwrap(); + let secondvec = ls.get(1).unwrap(); + let firstvec = match firstvec { + SCons(a, b) if **a == Atom(Vector) => *b.clone(), + t => t.clone(), + }; + let secondvec = match secondvec { + SCons(a, b) if **a == Atom(Vector) => *b.clone(), + t => t.clone(), + }; + let mut res = Atom(Nil); + for exp in firstvec.parts().into_iter().chain(secondvec.parts()).rev() { + res = scons(exp, res); + } + Ok(scons(Vector, res)) + }, + + // Arithmetic |