summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-26 09:53:02 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-26 09:53:02 +0000
commit794e0d2b6a7c8b15a302b0bb26c9d0d342d38a61 (patch)
treea1e88f690c272da5bfa3040fc24563d29d02757e /functions.c
parentbcaf7f25f42b21067a26895e097ada73765ba7d5 (diff)
Implement monadic ≡ (depth)
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/functions.c b/functions.c
index 7952565..9eb6406 100644
--- a/functions.c
+++ b/functions.c
@@ -30,7 +30,7 @@ fnmonad monadfunctiondefs[] = {
0, /* < */
0, /* > */
0, /* ≥ */
- 0, /* ≡ */
+ fnDepth, /* ≡ */
fnTally, /* ≢ */
0, /* ∨ */
0, /* ∧ */
@@ -367,6 +367,16 @@ fnSame(Array *right)
}
Array *
+fnDepth(Array *right)
+{
+ int uniform;
+ int depth = arraydepth(right, &uniform);
+ if(!uniform)
+ depth = -depth;
+ return mkscalarint(depth);
+}
+
+Array *
fnTally(Array *right)
{
return mkscalarint(right->rank==0 ? 1 : right->shape[0]);