From 794e0d2b6a7c8b15a302b0bb26c9d0d342d38a61 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Wed, 26 Jan 2022 09:53:02 +0000 Subject: =?UTF-8?q?Implement=20monadic=20=E2=89=A1=20(depth)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'functions.c') 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, /* ∧ */ @@ -366,6 +366,16 @@ fnSame(Array *right) return right; } +Array * +fnDepth(Array *right) +{ + int uniform; + int depth = arraydepth(right, &uniform); + if(!uniform) + depth = -depth; + return mkscalarint(depth); +} + Array * fnTally(Array *right) { -- cgit v1.2.3