Heh... As you suspected, "Here be Dragons". You get a SYNTAX ERROR when APL
discovers that the result would require an array containing a function.
Dyalog does not (yet) support arrays of functions. We're still weighing
whether to do hooks and forks, arrays of functions, or something completely
different (and will probably do nothing for a while longer, there is much
other work to do that is easier to decide on).

Interestingly, an array of objects can give you something which smells a lot
like an array of functions:

    nss gets quad-NS each 3 reshape enclose ''

nss is now an array of three empty "namespaces". A namespace is a kind of
typeless object into which you can insert any functions or variables that
you like (see http://www.dyalog.com/help/html/create%20namespace.htm) - I
think you have something similar in J, but am not sure whether you can have
an array of "references to" J namespaces(?). Pity about the quad-NS, perhaps
we can come up with a proper language element for an empty namespace in the
future - I always thought ¤ (sol) looks like a very small object :-)

So (3 take ¤) could give you three empty namespaces (3 reshape ¤) has to
give you three references to the SAME empty namespace, references are a
little alien to APL and J but you quickly get used to them and they are very
useful. Anyway... Now, in current Dyalog you can follow up with:

    nss.execute 'f gets {omega*2}' 'f gets +/' 'f gets {omega}'

Each namespace now contains a different f, as the elements of the array
above distributed to execute in each namespace. Since we did not have to
build an actual array of functions at any point, we got away with it. And we
can now call all the f's at once:

    nss.f (1 2 3) (4 5 6) (7 8 9)
1 4 9   15   7 8 9

We call this "distribution of functions", see
http://www.dyalog.com/help/html/arrays%20of%20namespace%20references.htm and
the preceding topic or two.

Morten

-----Original Message-----
From: Roger Hui [mailto:[EMAIL PROTECTED] 
Sent: 27. december 2007 19:04
To: Chat forum
Subject: Re: [Jchat] J readability

> Now, while ". in J seems not to want to return verbs or (and you 
> CAN understand its reluctance), the Dyalog execute primitive is 
> less picky ...

What happens with
   execute each '{alpha+omega}' '+/' '.' '{omega}'

Just curious.


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to