Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Vector of functions in APL

What is the syntax for a vector (array) of functions in APL?

I have tried the following but these are interpreted as a 3-train and a 2-train, respectively:

{1},{2}
{1} {2}

PS. I am looking to do this with more complex (and possibly named) functions by the way, the {1} above is just so the example is short.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Dyalog APL does not officially support function arrays, you can awkwardly emulate them by creating an array of namespaces with identically named functions.

      (a←⎕NS⍬).f←2∘×
      (b←⎕NS⍬).f←÷∘2
      (c←⎕NS⍬).f←-
      f←(a b c).f
      f 4
8 2 ¯4

Maria Wells suggested an operator to produce an array of functions

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading