diff options
-rw-r--r-- | apl9.h | 1 | ||||
-rw-r--r-- | functions.c | 19 |
2 files changed, 19 insertions, 1 deletions
@@ -310,6 +310,7 @@ Array *fnShape(Array *); Array *fnReverseLast(Array *); Array *fnReverseFirst(Array *); Array *fnTranspose(Array *); +Array *fnExecute(Array *); Array *fnSelfReference1(Array *); /* Dyadic functions from function.c */ diff --git a/functions.c b/functions.c index 9eb6406..c4b5cee 100644 --- a/functions.c +++ b/functions.c @@ -57,7 +57,7 @@ fnmonad monadfunctiondefs[] = { fnReverseLast, /* ⌽ */ fnReverseFirst, /* ⊖ */ fnTranspose, /* ⍉ */ - 0, /* ⍎ */ + fnExecute, /* ⍎ */ 0, /* ⍕ */ fnSelfReference1, /* ∇ */ }; @@ -715,6 +715,23 @@ fnTranspose(Array *right) } Array * +fnExecute(Array *right) +{ + if(right->type != AtypeRune) + throwerror(nil, EType); + Rune *code = pparray(right); + Datum *result = evalline(code, nil, 1); + free(code); + if(!result) + throwerror(L"No result produced by ⍎", EDomain); + if(result->tag != ArrayTag) + throwerror(L"Result of ⍎ must be an array", EType); + Array *res = result->array; + free(result); + return res; +} + +Array * fnSelfReference1(Array *right) { DfnFrame *dfn = getcurrentdfn(); |