Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!spool.mu.edu!umn.edu!csus.edu!sfsuvax1.sfsu.edu!emclean
From: emclean@sfsuvax1.sfsu.edu (Emmett McLean)
Subject: (J) Simultaneous column assignment into a list
Message-ID: <1993Jan5.041611.15629@csus.edu>
Sender: news@csus.edu
Organization: San Francisco State University
Distribution: NA
Date: Tue, 5 Jan 1993 04:16:11 GMT
Lines: 51

 This is an inquiry for a verb allowing simultaneous 
 column assignment into a list. In pseudo code
 with bracket indexing, it is : (*see below for the
 pseudo code for a statisfactory alternative.)
 w 
9 7 7  6  1 6 8
2 4 7  4 20 2 3
1 4 8  9 40 9 5
 s
30  1 
50 20
90 40
 w[;3 4] =. s
 w
9 7 7 30  1 6 8
2 4 7 50 20 2 3
1 4 8 90 40 9 5

 Here's a solution but it's hardly elegant:

 ca =. >@{:@]`($@[ #. (i.@$@>@{: ,. >@{.)@])`[}
 ca1 =. >@}.@]`($@[ #. (i.@$@>@}. ,"0/ >@{.)@])`[} NB. column assign
 (BTW ca1 is another version of ca which works on v6.1 the NeXt but 
  yeilds a length error on v6.1 on the VAX)

 mca =. i. 0 0 NB. multiple column assign
 mca =. mca,'loop) $. =. > (0 = # y.) { cont ; end'
 mca =. mca,'cont) x. =. x. ca {. y.'
 mca =. mca,'y. =. }. y.'
 mca =. mca,'$. =. loop'
 mca =. mca,'end) y. =. x.'
 mca =.'': mca
 d =. ,: 3 ; 30 50 90
 ]d =. d, 4 ; 1 20 40
+-+--------+
|3|30 50 90|
+-+--------+
|4|1 20 40 |
+-+--------+
  w mca d
9 7 7 30  1 6 8
2 4 7 50 20 2 3
1 4 8 90 40 9 5

 *Actually, it might be more straight forward to cook up an
  alternative verb whose pseudo code is :

  w[;3 4] =. w[;3 4] + 1 2 3 ,. 4 5 10

  Thanks,
  Emmett
