Gilles Kirouac wrote:
>
>
> [...]
>
> diagonal =: ( {."_1~ -@:>:@:i.@:# )
>
> diagonal 99 1x1 0 _1j1 99
> 99 0 0 0 0
> 0 2.71828 0 0 0
> 0 0 0 0 0
> 0 0 0 _1j1 0
> 0 0 0 0 99
> [...]
>
> ( {.!.'.'"_1~ -@:>:@:i.@:# )'abcdef'
>
> a
> .b
> ..c
> ...d
> ....e
> .....f
>
Slightly shorter version:
( {.!.'.'"_1~ _1 - i.@:# )'abcdef'
> or with a variable fill atom (but not tacitly in this form I think):
> '*'( 4 : '(->:i.# y) {.!.x "_1 y' ) 'abcdef'
> [...]
>
Interestingly enough, there is a tacit version of your verb:
D=:{.!.("_1)~(`(_1-i.@:#))(`:6)
'*' D 'abcde'
a
*b
**c
***d
****e
D is an adverb that can also give us other verbs:
'.' D
{.!.'.'"_1~ (_1 - i.@:#)
--
View this message in context:
http://www.nabble.com/diagonal-arrays-tp19935328s24193p23207670.html
Sent from the J Programming mailing list archive at Nabble.com.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm