Not simply this?

+/2 3 4 2

11


Cheers,

Erling


On 2016-09-27 09:35, Skip Cave wrote:
NB. I am attempting to learn recursion using ^:


NB. A simple recursion:


    2+^:(3) 2

8


NB. This is equivalent to


2+2+2+2

8


NB. What if I want to change the left argument on each recursion?

NB. Instead of 2 each time, I want to add 2, then 3, then 4.

NB. I know there are much easier ways to do this, but I want to see

NB. if I can avoid do. while. loops if the left argument changes on each
iteration


NB. I tried


(2 3 4)+^:(3) 2

8 11 14


NB. Nope. That didn't work.

NB. What I want to achieve is:


2+3+4+2

11

NB. but do it recursively using ^:

Skip

Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
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