For positive/negative scalars,
(| | >&0 -~ [: +/\ |#*)

works. At its core it is

(| | [: +/\ |#*)

which works for negative lengths but must be decremented for positive
lengths. Another option is
(-@>&0 |. | | [: +/\ |#*)
.

Marshall

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Thursday, November 04, 2010 9:23 AM
To: Programming forum
Subject: Re: [Jprogramming] A nice example of &. and some related
observations

On Thu, Nov 4, 2010 at 4:57 AM, R.E. Boss <[email protected]> wrote:
> Stumbled the other day on
>
>   ([: +/\&.:>: #&0) 5
> 0 1 2 3 4

You could also use (_1 + +/\...@#&1) or +/\@:-...@{.&1.

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