aboutsummaryrefslogtreecommitdiff
path: root/source/primitives/conditional.d
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-04-16 00:12:37 +0200
committerAdrian Kummerlaender2019-04-16 00:12:37 +0200
commit908d8f01d5e964971ad76909c0ec31468ee93d2d (patch)
treef1f9a84928b39aabc4792544951797b8a9eb1bfa /source/primitives/conditional.d
parent1b92af67088b5e57f9134703ae6115c3529fb352 (diff)
downloadslang-908d8f01d5e964971ad76909c0ec31468ee93d2d.tar
slang-908d8f01d5e964971ad76909c0ec31468ee93d2d.tar.gz
slang-908d8f01d5e964971ad76909c0ec31468ee93d2d.tar.bz2
slang-908d8f01d5e964971ad76909c0ec31468ee93d2d.tar.lz
slang-908d8f01d5e964971ad76909c0ec31468ee93d2d.tar.xz
slang-908d8f01d5e964971ad76909c0ec31468ee93d2d.tar.zst
slang-908d8f01d5e964971ad76909c0ec31468ee93d2d.zip
Play around with a vector typeHEADmaster
Using _vectors_ as fundamental datatype could make for a really neat experience. Imagine e.g.: * fundamental arithmetic operations that apply to both vectors and scalars * implicit component-wise or vector-wise operations * scalar values as 1D vectors * higher order functions to manipulate those vectors * `map` function that applies a (quoted?) word to all vector elements and returns the result * efficient parallel operations * a rich library of vector manipulation functions * or even: matrices as a fundamental datatype? * problem: probably harder to conveniently enter via a 1-D repl * sound more and more like a RPN version of APL… Back to reality, here is what this prototype actually adds: * new `DList!int` based datatype alongside the existing int, string and bool types * basic support for printing such values in a readable fashion * new fundamental `:` word that constructs a vector of two elements * `1 2 :` yields `[1, 2]` * adapted `+` and `*` to support component-wise operations * `1 2 : 3 +` yields `[4, 5]`
Diffstat (limited to 'source/primitives/conditional.d')
-rw-r--r--source/primitives/conditional.d3
1 files changed, 2 insertions, 1 deletions
diff --git a/source/primitives/conditional.d b/source/primitives/conditional.d
index fd101bd..62a9fc5 100644
--- a/source/primitives/conditional.d
+++ b/source/primitives/conditional.d
@@ -19,7 +19,8 @@ bool handle(Token token) {
return token.visit!(
(int ) => capture(token),
(bool ) => capture(token),
- (string word) => handle(word)
+ (string word) => handle(word),
+ (DList!int ) => capture(token)
);
}