Thinking out of my box. 
Clever interpretation of the pattern.

R.E. Boss


> -----Original Message-----
> From: [email protected] [mailto:programming-
> [email protected]] On Behalf Of Henry Rich
> Sent: dinsdag 9 december 2014 13:50
> To: [email protected]
> Subject: Re: [Jprogramming] more elegant solution?
> 
>     a =. <:/~i.5
>     (#.@}: + {:)\"1&.|: a
> 1  1  1  1  1
> 1  2  2  2  2
> 2  3  4  4  4
> 4  6  7  8  8
> 8 12 14 15 16
> 
> Henry Rich
> 
> On 12/9/2014 6:56 AM, R.E. Boss wrote:
> > Given the matrix
> >     <:/~i.5         NB. 5 could be any positive integer
> > 1 1 1 1 1
> > 0 1 1 1 1
> > 0 0 1 1 1
> > 0 0 0 1 1
> > 0 0 0 0 1
> > I want to generate
> > 1  1  1  1  1
> > 1  2  2  2  2
> > 2  3  4  4  4
> > 4  6  7  8  8
> > 8 12 14 15 16
> > which one would expect to construct with
> >     ((+ +/),])/&.|.<:/~i.5
> > but then
> > 1 1 1 1 1 6 6 6 6 5 35 35 35 34 34 208 208 207 207 207 1245 1244 1244
1244
> > 1244
> >
> > Of course I can think of all kind of solutions of which
> >     (3 : ('z=.(1-#y)}.y';'for_k. }.i.#y do. z=.z, (k{y) + +/z
end.';'z'))
> > <:/~i.5
> > I regard the most satisfactory.
> > Does anyone has a more elegant tacit solution then
> >     (((+ +/),]),:^:(1=#@$))/&.|. <:/~i.5
> > 1  1  1  1  1
> > 1  2  2  2  2
> > 2  3  4  4  4
> > 4  6  7  8  8
> > 8 12 14 15 16
> >
> >
> > R.E Boss
> >
> > ----------------------------------------------------------------------
> > For information about J forums see
> http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to