Raul Miller wrote:
>When you need to intermix three (or more) values in J,
>you have several options:
>
>[1] Compose some (or all) of them into a list
>[2] Use an explicit definition
>[3] recompute some of them

In the specific case of "three" values:

[4] Consider going the route adverb, or rather, adnoun, as I call
    them in this case.
    The adnoun gobbles up the first value, the derived verb the
    second and third.  Mind the positioning, though.

Within the primitives, the adverb Amend "}" is a good example:

   'x' 1} 'ABC'
AxC

For practical purposes, this looks, works, and quacks like a three argument
function, certainly to many J newbies.  While it isn't.

One of my pet adnouns is "concatenate two strings using a delimiter":

join =: 1 : 0
:
   x , m , y
)

   'wendy' '*'join 'lisa'
wendy*lisa

   NB. more used like this:
   '.'join&":/  217 13 66 166
217.13.66.166


In the same vein, the following is a not very difficult exercise I
usually give in my commercial J courses.  It is *always* both fun
and enlightning for the participants.

I give:

Write a conjunction C which allows you to do:

   'foo' ','C'()' 'bar'
(foo),(bar)

   ' and 'C'|'/   1;2;3; ;:'john paul george ringo'
|1| and |2| and |3| and |john| and |paul| and |george| and |ringo|

(I also use the exercise to talk about "creeping featurism"
and "coding economics" in the specific context of J.)

Exercise for the *advanced* Jer:

Don't send the (pretty trivial) spoiler to the above but keep the
answer to the above to yourself.  Instead, code C tacitly.  Keep
the answer to yourself.

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

Reply via email to