Very good.
I should have posed the question for non-empty arrays,
in which case your solution would have been nearly
identical to mine but for one character. The one character
difference is that I used @ where you'd used @: .
See "nmat" in
http://www.jsoftware.com/jwiki/Essays/Boxed_Array_Display#HTML
Raul's solution is (I believe) the same as ours modulo
some algebraic simplification.
This is one of those rare cases where APL is shorter than J:
nl←{1++/¯1+×\¯1↓⍴⍵}
----- Original Message -----
From: Henry Rich <[email protected]>
Date: Friday, April 2, 2010 15:57
Subject: Re: [Jprogramming] lines in display
To: Programming forum <[email protected]>
> nl =. +/&.:<:@:(*/\)`0:@.(0&e.)@}:@$
> nl i. 3 4 5
> 14
> nl i. 0 0
> 0
> nl i. 0 1
> 0
> nl i. 1 0
> 1
> nl i. 2 2 2 2 1
> 27
>
> The agenda part is to handle the case of empty operands, which
> seem
> anomalous:
>
> i. 0 2 3
>
> displays nothing, which I expect, but you could make a case that
>
> i. 2 0 3
>
> should display a space between two empty arrays. I assume
> that the
> observed behavior is better thought out than my first guess.
>
> Henry Rich
>
> Roger Hui wrote:
> > If x is a rank 2 or higher numeric array, how many
> > lines are in the display of x? For example,
> > there are 14 lines in the display of i. 3 4 5 .
> >
> > I've worked on a related problem on-and-off for years,
> > starting in 1991, and only came to a good answer
> > for this problem just a few days ago.
> > ---------------------------------------------------------------
> -------
> > 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