[comp.lang.apl] Indexed assignment in J

loc@tmsoft.UUCP (Leigh Clayton) (01/11/91)

 Another message from rbe@yrloc.ipsa.reuter.com (Bob Bernecky).

>no. 4831177 filed 17.02.55  thu 10 jan 1991
>from rbe@ipsa
>to   loc@ipsa
>cc   clapl
>subj merging in J
>
>@transferred from ipsa  no. 4665548 filed 17.02.52  thu 10 jan 1991
>
>One way to get the effect of x[i]?k in j is to use merge:
>
>x =. k i{x
>
>That is, merge the elements of k into positions i of x, and
>assign the resulting array back into x. It is essentially a
>functional form of indexed assignment, witut the side effect
>which is present in APL of destroying the original array.
>
>The justification for making catenate work along the first axis
>is that you only then need one functional form, comma, rather than
>comma, comma-bar, and comma with bracket axis operator. The use
>of rank reduces the number of primitives needed, simplifies the
>teaching and use of the language, and unifies the treatment of
>operations along other axes, by use of the rank adverb.
>
>Generally:
>
>APL           J
>
>x,y           x,"1 y
>x?y           x,y
>x,[k]y        x,"k y
>
>where k is origin 0.
>
>There is another way to do the merge, but I can't seem to make it work
>in my version of J. Bob
>

-----------------------------------------------------------
- Men argue, Nature acts                       /Voltaire  -
-----------------------------------------------------------
loc@tmsoft.UUCP   (Leigh Clayton)   uunet!mnetor!tmsoft!loc