This is nice, and I wanted to take it further:
'*' (<a:;1) } 2 9$'-' NB. A[;1] origin 0
-*-------
-*-------
'*' (<1;<a:) } 2 9$'-' NB. A[1;]
---------
*********
'*' (<1 ; 2 3) } 2 9$'-' NB. A[1;2 3]
---------
--**-----
'*' ((0;3 4);(<1;5 _2)) } 2 9$'-'
---**----
-----*-*-
('34',:'56') ((0 1;3);(<1 2;5)) } 3 9$'-' NB. guitar tabs, anyone?
---3-----
---4-5---
-----6---
(for cords see
http://www.jsoftware.com/pipermail/general/2005-January/019929.html )
But then the fun ends,
'*' ((0;3 4);(<1;5)) } 2 9$'-'
|domain error
| '*' ((0;3 4);(<1;5))}2 9$'-'
'*' ((0;3);(<0 1;5)) } 2 9$'-'
|domain error
| '*' ((0;3);(<0 1;5))}2 9$'-'
For some reason, although everything is boxed,
it is not generalized to unmatching lists of indices.
Moreover, corresponding { does not give an error.
((0;3 4);(<1;5)) { i.2 9
3 4
14 0
((0;3);(<0 1;5)) { i.2 9
3 0
5 14
It actually was working, according to the { rule above,
until it was "fixed" (to return domain error)
http://www.jsoftware.com/pipermail/programming/2006-July/002815.html
There is also a neat but somewhat expesive wrokaround,
http://www.jsoftware.com/pipermail/programming/2006-July/002819.html
Which brought us to also unfetch (a topic of a separate thread)
http://www.jsoftware.com/pipermail/programming/2006-July/002830.html
Can the { rule for } be viewed as not-completely-symmetrical
case as in perfectly tolerated
{&1 2 2 3 b._1
1 2 2 3&i.
]&.({&1 2 2 3) 1 2 3
1 1 3
so that the non-matching indices could actually be possible,
less setting the top-left item, instead of giving domain error?
--- bill lam <[EMAIL PROTECTED]> wrote:
> Chris had contributed a series of articles to vector to introduce J for
> APLers,
> including axis and amend. a: means taking all elements for that axis. In
> particular a:{table is table.
>
> They should be available in jwiki.
>
> Sherlock, Ric wrote:
> > Thanks to you all for the helpful answers and also to Devon for the
> > explanations.
> > Chris' response had me stumped for a while until I realised that it was
> > pretty much the equivalent of APLs table[;1]
> >
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Chris Burke
> > Sent: Wednesday, 7 February 2007 18:44
> > To: Programming forum
> > Subject: Re: [Jprogramming] Amending columns
> >
> > Sherlock, Ric wrote:
> >> Am new to J (from APL) and am having trouble with selective assignment
> > .
> >> I understand that in J the equivalent is to use Amend.
> >> Given:
> >> ]table=.4 2$ ;:'taa tas ewe wtw tweqewqwq 4212 fgsaera jihjy'
> >> ]newcol=. ;:'mean to been formed'
> >> ]newrow=. ;:'thra rowskd'
> >>
> >> Lets say I want to replace the 2nd column of table with a new column.
> >> The following works:
> >> newcol (0 1;1 1;2 1;3 1)}table
> >>
> >> But this doesn't:
> >> newcol 1}"1 table
> >> |rank error
> >> | newcol 1}"1 table
> >
> > Also:
> >
> > newcol (<a:;1)} table
____________________________________________________________________________________
8:00? 8:25? 8:40? Find a flick in no time
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm