summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-12 00:09:12 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-12 00:09:12 +0000
commit85aa2ad424c68343ef09e5f6df243ad6499e47d5 (patch)
tree8712baf633e82ffdba79b3a59b17734de0eaf4d7 /functions.c
parent2ff4b85fc73f0cf82034e2a19ea8c5d677812c9c (diff)
Add a small version of monadic ⍳ and some simple form of ⎕IO
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/functions.c b/functions.c
index cf5402a..4d9a69f 100644
--- a/functions.c
+++ b/functions.c
@@ -44,7 +44,7 @@ fnmonad monadfunctiondefs[] = {
0, /* ⌷ */
0, /* ⍋ */
0, /* ⍒ */
- 0, /* ⍳ */
+ fnIndexGenerator, /* ⍳ */
0, /* ⍸ */
0, /* ∊ */
0, /* ⍷ */
@@ -143,6 +143,19 @@ fnEnclose(Array *right)
}
Array *
+fnIndexGenerator(Array *right)
+{
+ /* TODO only works for creating vectors */
+ vlong n = right->intdata[0];
+ Array *res = mkarray(AtypeInt, 1, n);
+ res->shape[0] = n;
+ vlong io = globalIO();
+ for(vlong i = 0; i < n; i++)
+ res->intdata[i] = i + io;
+ return res;
+}
+
+Array *
fnNest(Array *right)
{
if(simplearray(right))