I came up with:

[: > ([: - [: i. $) |.&.> # {.&.> ]

Probably done already, but with the double "each", its efficiency is
questionable.

While thinking about this, a thought  occurred to me generalise this to
higher rank arrays, so for example would need a rank 2 argument for rank 3
diagonal arrays -- didn't get beyond the thought though :-)

enjoy
ken

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike Day
Sent: 12 October 2008 13:01
To: Programming forum
Subject: Re: [Jprogramming] diagonal arrays

True of my offering too - pity!
   (*=) 2 7 9 2
|length error
|       (*=)2 7 9 2

Mike

Arie Groeneveld wrote:
> Hmm, only applicable for arrays with different elements?
>
>    (*]=,/\) 3 3 4 5
> 3 0 0 0
> 3 3 0 0
> 0 0 4 0
> 0 0 0 5
>
>
>
> Arie Groeneveld schreef:
>   
>>    (*]=,/\)2 7 9 20
>> 2 0 0  0
>> 0 7 0  0
>> 0 0 9  0
>> 0 0 0 20
>>
>>
>> =@@i
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>
>>   
>>     
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com 
> Version: 8.0.173 / Virus Database: 270.8.0/1717 - Release Date: 09/10/2008
16:56
>
>   

----------------------------------------------------------------------
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