From 85aa2ad424c68343ef09e5f6df243ad6499e47d5 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Wed, 12 Jan 2022 00:09:12 +0000 Subject: =?UTF-8?q?Add=20a=20small=20version=20of=20monadic=20=E2=8D=B3=20?= =?UTF-8?q?and=20some=20simple=20form=20of=20=E2=8E=95IO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'functions.c') 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, /* ⍷ */ @@ -142,6 +142,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) { -- cgit v1.2.3