Catalogue still generates the "full-scan" cartesian
cube, as opposed to APL's vector per axis.
In the cube situation, it is better IMO to use the
other convention of } (not very prominently shown in
Dictionary for { From):
(%ix{a) (ix=.<(1+i.2);2+i.3) } a=. i.5 6
0 1 2 3 4 5
6 7 0.125 0.111111 0.1 11
12 13 0.0714286 0.0666667 0.0625 17
18 19 20 21 22 23
24 25 26 27 28 29
You can furhter optimize this to allow
special code in } for in-place assignment.
Cf. on large scale
<(1+i.2);2+i.3
+-----------+
|+---+-----+|
||1 2|2 3 4||
|+---+-----+|
+-----------+
{(1+i.2);2+i.3
+---+---+---+
|1 2|1 3|1 4|
+---+---+---+
|2 2|2 3|2 4|
+---+---+---+
--- Graham Parkhouse <[EMAIL PROTECTED]> wrote:
> Devon, this is exactly what I was hoping for! Catalogue (monadic {) is what
> I was missing. Bravo!
> I had seen catalogue but hadn't realized its usefulness for such a context
> as this.
>
> In JfC, Henry writes, under Modification in Place, "Profligacy with memory
> bandwidth reaches an
> extreme with dyad m} : even if y is huge and only one atom is modified, the
> whole y must be copied
> to produce the result. Sometimes this can be a noticeable drag on
> performance. To help out in
> those cases, the interpreter recognizes the specific forms
>
> name =. x m} name
> name =: x m} name
> name =. name , x
> name =: name , x
>
> and executes the modification in place, i. e. without creating a new copy of
> name . For the
> modification to be in-place, there must be nothing else in the sentence
> either before or after the
> form shown above, and the two appearances of name must be identical. x and
> m may be any
> expressions that evaluate to nouns."
>
> So the interpreter wouldn't recognize your occurrence as you have written
> it?
>
> And, Raul, you wrote "I think you are asking about } but, depending on what
> you are really looking
> for, you have more options." I was asking about }, but would be interested
> in other ways. Devon's
> is fine, but it's not as concise as I was used to in APL.
>
> Many thanks to you both.
>
> Graham
>
> On Fri, 26 Oct 2007 18:02:02 -0400 Devon McCormick wrote:
> >
> > Graham,
> >
> > since you supplied no example, I'm guessing at what you want. Maybe
> something like this?
> >
> > mat=. 10 10$0
> > ]mat=. (9+ix{mat) ix}mat [ ix=. {(2+i.4);(3+i.6)
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 9 9 9 9 9 9 0
> > 0 0 0 9 9 9 9 9 9 0
> > 0 0 0 9 9 9 9 9 9 0
> > 0 0 0 9 9 9 9 9 9 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > ]mat=. (99+ix{mat) ix}mat [ ix=. {(1+i.7);(3+i.2)
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 99 99 0 0 0 0 0
> > 0 0 0 108 108 9 9 9 9 0
> > 0 0 0 108 108 9 9 9 9 0
> > 0 0 0 108 108 9 9 9 9 0
> > 0 0 0 108 108 9 9 9 9 0
> > 0 0 0 99 99 0 0 0 0 0
> > 0 0 0 99 99 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> >
> > Regards,
> >
> > Devon
> >
> > On 10/26/07, Graham Parkhouse <[EMAIL PROTECTED]> wrote:
> > >
> > > In APL by writing a loop containing
> > >
> > > matrix[i1;12]+ <- submatrix
> > >
> > > I can build a matrix from a number of contributing submatrices. What
> > > is a neat equivalent phrase in J?
> > >
> > > Thanks in anticipation!
> > >
> > > Graham Parkhouse
> > >
> > >
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > >
> >
> >
> >
> > --
> > Devon McCormick, CFA
> > ^me^ at acm.
> > org is my
> > preferred e-mail
> >
> >
> > ------------------------------
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm