Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NARS2000 has no documentation on how to dynamically define a function

Tags:

apl

I'm frustrated by the lack of clear documentation in NARS2000.

For example, I don't know how to define a function yet. ( I know I can use trains, but that's beside the point. )

  AVG←{(+/⍵)÷⍴⍵} ⍝ computes the average
SYNTAX ERROR
  AVG←{(+/⍵)÷⍴⍵} ⍝ computes the average
                                       ∧

Then,

  AVG←(+/⍵)÷⍴⍵ ⍝ computes the average
VALUE ERROR
  AVG←(+/⍵)÷⍴⍵ ⍝ computes the average
            ∧

At this point, I really starting to wonder if NARS2000 uses in function definition.

So how do I do define a function?

like image 230
Zchpyvr Avatar asked Feb 03 '26 06:02

Zchpyvr


2 Answers

Good news! As of version 0.4.0.29 (2 Aug 2013) NARS2000 supports Anonymous Functions (a.k.a. dynamic functions). For more details, see the Wiki.

like image 74
Bob Smith Avatar answered Feb 06 '26 06:02

Bob Smith


Omega ( ⍵ ) is an identifier in NARS2000. You create a function either with the del operator or with the )EDIT command. So if you wanted to define an avg function:

)edit avg

[0] r←avg arg
[1] r←(+/arg)÷⍴arg

Control E to save, then do

   a←5 10 15 20
   avg a

12.5

like image 33
Paul Robinson Avatar answered Feb 06 '26 06:02

Paul Robinson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!