Here's a pretty good version:
cross =: {~`(],#@[->:@])`(' '"0~[)}"_ 0 i.@#
cross 'abcde'
a a
b b
c
d d
e e
The important simplification here is to do it by lines and not build the
whole structure at once.
Marshall
On Sun, Dec 09, 2012 at 08:42:13PM -0600, km wrote:
> Write verb cross.
>
> cross 'abcde'
> a a
> b b
> c
> d d
> e e
>
> (Result should look like a cross with 'abcde' along both diagonals.)
>
> cross 'a'
> a
> cross 'ab'
> aa
> bb
>
> Kip Murray
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm