Here's yet another successively "better" answer
working for any rank
+/ , M * M = (+/@#: i.) $ M=. i.2 3 4
6
0j8 0":10 ts '+/ , M * M = +/&> {i.&.> $ M' [ M=. i.20 30 40
0.01522392 2194752
0j8 0":10 ts '+/ , M * M = (+/@#: i.) $ M' [ M=. i.20 30 40
0.01446958 428352
--- Roger Hui <[EMAIL PROTECTED]> wrote:
> I might say:
>
> +/ , M * M = +/&> {i.&.> $M
> 6
>
> If I were under pressure (e.g. with Dijkstra in the audience
> asking the question) and wanted to avoid any fumbling,
> I might say:
>
> +/ , M * M = (i.#M) +/ i.{:$M
> 6
>
> And then from that to successively "better" answers
> +/ , M * M = (#M) +/&i. {:$M
> +/ , M * M = +/&i./ $M
> +/ , M * M = +/&> {i.&.> $M
> not forgetting to point out that the last expression
> works for M of any rank.
>
> Dijkstra's question in 1963 was: How would you represent a
> more complex operation, for example, the sum of all elements of
> a matrix which are equal to the sum of the corresponding row
> and column indices?
>
>
>
> ----- Original Message -----
> From: Oleg Kobchenko <[EMAIL PROTECTED]>
> Date: Wednesday, November 7, 2007 17:00
> Subject: Re: [Jchat] why did Dijkstra dislike APL so much?
> To: Chat forum <[email protected]>
>
> > What is the standard J answer?
> >
> > ((= +/@#&, [) +/&i./@$) i.3 4
> > 6
> > (+/@#~&, (= +/&i./@$)) i.3 4
> > 6
> > (+/@,@:* (= +/&i./@$)) i.3 4
> > 6
> > +/,M*M=+/&i./$ M =. i.3 4
> > 6
> >
> >
> > --- Roger Hui <[EMAIL PROTECTED]> wrote:
> >
> > > I don't know of any and I suspect Ken was too smart to respond.
> > >
> > > There was an encounter between KEI and Dijkstra recorded in
> > > http://keiapl.info/anec/#Dijkstra
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: Richard Hill <[EMAIL PROTECTED]>
> > > Date: Wednesday, November 7, 2007 15:21
> > > Subject: Re: [Jchat] why did Dijkstra dislike APL so much?
> > > To: Chat forum <[email protected]>
> > >
> > > > Is there any record, or even an anecdote, of KEI's
> > > > own response to Dijkstra's comment?
> > > > Richard Hill
> ----------------------------------------------------------------------
> 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