On Wed, Oct 29, 2008 at 16:21, Raul Miller <[EMAIL PROTECTED]> wrote:
>   f=: ] {~ ~: >./\@:* [EMAIL PROTECTED]@]

Nice.

I wondered if I could use prefix (u\ monad) somehow, like this:

   0 (i:&1\@:~: { ]) 1 0 2 3 4 5 0 0 0 4 3 2 4
1 1 2 3 4 5 5 5 5 4 3 2 4

but then I decided I couldn't, for it would make the solution quadratic-time.

Yours however uses >./\ which has special code to run in linear time,
thus avoiding the problem.

Ambrus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to