Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!cs.utexas.edu!uwm.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!ames!purdue!mentor.cc.purdue.edu!mentor!weg
From: weg@mace.cc.purdue.edu (Eythan Weg)
Subject: Re: Selective assignment (was Re: J is NOT APL)
In-Reply-To: rockwell@socrates.umd.edu's message of Mon, 1 Feb 1993 14:28:20 GMT
Message-ID: <WEG.93Feb1135334@mace.cc.purdue.edu>
Sender: news@mentor.cc.purdue.edu (USENET News)
Organization: Purdue University
References: <1993Jan26.184600.24394@csi.jpl.nasa.gov> <1993Jan27.094037.13820@csus.edu>
	<1993Jan27.221845.11152@csi.jpl.nasa.gov>
	<1993Jan29.233943.5662@csus.edu>
	<ROCKWELL.93Feb1092820@socrates.umd.edu>
Date: Mon, 1 Feb 1993 18:53:33 GMT
Lines: 51

In article <ROCKWELL.93Feb1092820@socrates.umd.edu> rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell) writes:


   Sam Sirlin:
   .  >   index=. ($@])#.[

   Emmett McLean:
   .   Lets look at two real cases :
   .
   .     x0 =. 100 
   .     i0 =. 0 2
   .     y0 =. i. 3 3
   .     x0 (i0 index y0) } y0
   .  0 1 100
   .  3 4   5
   .  6 7   8
   ...
   .
   .      And :
   ...
   .     i1 =. 0 6
   .     x0 (i1 index y0) } y0
   .    0 1 2
   .    3 4 5
   .  100 7 8
   .
   .     For the example x0, i0, and y0 your method works nicely. Unfort-
   .     unately, for the example of x0, i1, and y0 it also works nicely!

   try
     index=. [ { i.@$@]

Here is one with error checking:
	index=.'e'"_`($@] #. [)@.([ -: [ <."1 <:&$@])
so one ca do:
	1 10 (>0 1 ; 2 2) index y0} y0
or 
	indx=.(&index)@].]

and then 
	1 10 (>0 1 ; 2 2) indx} y0
may work.
And then one can say:
	insert=.indx}
so 
	1 10 (>0 1 ; 2 2) insert y0

I not convinced that it worth my effort.  I like Sam's little trick,
which is at the heart of index.  It is memorable and very close to
basics.
Eythan
