On Mon, Mar 28, 2011 at 5:01 AM, Adrian May
<[email protected]> wrote:
> In principle, I want to build a list recursively using some function to
> generate each element from the previous one, up to a certain length. I tried
> it with /\ but just got strange results:
>
>   (2*[)/\ 2 3 4
> 2 4 4

It occurred to me finally, what you were expecting here.

The issue I think you are describing is
   / computes results from right to left
   \ accumulates results from left to right

The simple approach to accumulating results in the same order that
they are computed would be to use \.
   (2*])/\. 4 3 2
8 4 2

A more complicated approach would be to do the double reverse cross thing:
   (2*[)~/\.&.|. 2 3 4
2 4 8

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

Reply via email to