summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-17 22:40:01 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-17 22:40:01 +0000
commit235f448cfdf7b6c1f1664cd32fa769670bdd0d6c (patch)
treefdac6164038ad257699c0c3eeffb60380c65fa16 /functions.c
parent0ef01858ce7685cb2faac5a2cddc6a2fd76de104 (diff)
Implement monadic ⍪ (table)
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/functions.c b/functions.c
index ef9aa97..eff944f 100644
--- a/functions.c
+++ b/functions.c
@@ -52,7 +52,7 @@ fnmonad monadfunctiondefs[] = {
0, /* ∩ */
0, /* ~ */
fnRavel, /* , */
- 0, /* ⍪ */
+ fnTable, /* ⍪ */
fnShape, /* ⍴ */
fnReverseLast, /* ⌽ */
fnReverseFirst, /* ⊖ */
@@ -217,6 +217,17 @@ fnRavel(Array *right)
}
Array *
+fnTable(Array *right)
+{
+ Array *res = duparray(right);
+ res->rank = 2;
+ res->shape = realloc(res->shape, sizeof(int) * 2);
+ res->shape[0] = right->rank ? res->shape[0] : 1;
+ res->shape[1] = right->size / res->shape[0];
+ return res;
+}
+
+Array *
fnShape(Array *right)
{
Array *res = allocarray(AtypeInt, 1, right->rank);