diff --git a/jsrc/CMakeLists.txt b/jsrc/CMakeLists.txt index 7c91ae9f..80f4d083 100644 --- a/jsrc/CMakeLists.txt +++ b/jsrc/CMakeLists.txt @@ -73,6 +73,7 @@ target_sources(j PRIVATE verbs/vsb.c verbs/vx.c verbs/vz.c + verbs/monadic/isempty.cpp verbs/monadic/rank.cpp verbs/monadic/same.cpp verbs/monadic/shape.cpp diff --git a/jsrc/verbs/monadic/isempty.cpp b/jsrc/verbs/monadic/isempty.cpp new file mode 100644 index 00000000..fd82c93c --- /dev/null +++ b/jsrc/verbs/monadic/isempty.cpp @@ -0,0 +1,15 @@ +#include "array.hpp" + +/** @file */ + +/** + * @brief `0 e. $` IsEmpty + * @param jt JST (J Syntax Tree) + * @param w Input aray + * @return boolean jtrue or jfalse + */ +[[nodiscard]] auto +jtisempty(J jt, array w) -> array { + if (is_sparse(w)) return jteps(jt, num(0), shape(jt, w)); + return AN(w) == 0 ? jtrue : jfalse; +} diff --git a/jsrc/verbs/v.c b/jsrc/verbs/v.c index e73ee98b..1e71c02b 100644 --- a/jsrc/verbs/v.c +++ b/jsrc/verbs/v.c @@ -4,12 +4,6 @@ /* Verbs */ #include "j.h" - -A -jtisempty(J jt, A w) { - if ((AT(w) & SPARSE) != 0) return jteps(jt, num(0), shape(jt, w)); - return AN(w) == 0 ? jtrue : jfalse; -} // 0 e. $ A jtisnotempty(J jt, A w) { if ((AT(w) & SPARSE) != 0) return jtnot(jt, jteps(jt, num(0), shape(jt, w)));