[Jprogramming] Several questions about j
Raul Miller
rauldmiller at gmail.com
Tue Mar 20 21:52:09 HKT 2012
After reading other people's responses in this thread, I thought I
should expand on the concept of "forwarding".
First off, there are different kinds of forwarding. There's
forwarding of results, and there's forwarding of definitions.
To make this concrete, let's pick a specific example.
3 # *: 4
16 16 16
Here's 16 is the intermediate result from *: 4 and this result gets
forwarded to # which in turn makes three copies of that result.
Simple, yes?
But let's say we wanted to make 3 copies of the definition of *: (or,
technically: 3 copies of the symbols which represent the definition of
*:) instead of making 3 copies of the result of *:
3 # *:`''
┌──┬──┬──┐
│*:│*:│*:│
└──┴──┴──┘
Expressing this in english would probably go something like this:
Original sentence: 3 copies of squaring
Result: squaring squaring squaring
So... again, this is simple. It's also a bit useless, which makes it
seem nonsensical -- what are we going to do with these three copies?
Using the copies wasn't really a part of the question, but J gives us
various ways to use them. For example, we could use each one
independently and stick all of their results together:
(3 # *:`'')(`:0) 4
16 16 16
--
Raul
On Mon, Aug 15, 2011 at 7:10 AM, Raul Miller <rauldmiller at gmail.com> wrote:I
> On Mon, Aug 15, 2011 at 5:08 AM, Kim Kuen Tang <kuentang at vodafone.de> wrote:
>> Are verbs ( dyad or monad) first-class citizen in j?
>
> The answer to this is "no" in the same sense that objects are not
> first-class citizens in any object oriented language.
>
>> Is it possible to forward a verb to another verb?
>
> Yes.
>
>> Is it possible to box a verb into list ?
>
> Yes.
>
>> Is it possible to have a dictionary like the case in kdb? Something
>> like : (`a`b`c)!(1 2 3)
>
> Yes, but not exactly.
>
> Typically, in J, locales are used for this purpose. But locales are
> not values and can only be referred to (by name).
>
> You would have to implement a replacement for this use of ! as a user
> defined verb.
>
> --
> Raul
More information about the Programming
mailing list