Re: [Jprogramming] Learning Recursion

2016-09-29 Thread Raul Miller
{:))) , (<@(}.@>@{:))) (<20),(<2 3 4) >> ┌──┬───┐ >> │22│3 4│ >> └──┴───┘ >> >> So let's apply *that* big verb three times: >>(((<@((>@{.) + ({.@>@{:))) , (<@(}.@>@{:))) ^:3) (<20),(<2 3 4) >> ┌──┬┐ >&

Re: [Jprogramming] Learning Recursion

2016-09-29 Thread Louis de Forcrand
{:))) , (<@(}.@>@{:))) (<20),(<2 3 4) >> ┌──┬───┐ >> │22│3 4│ >> └──┴───┘ >> >> So let's apply *that* big verb three times: >> (((<@((>@{.) + ({.@>@{:))) , (<@(}.@>@{:))) ^:3) (<20),(<2 3 4) >> ┌──┬┐ >

Re: [Jprogramming] Learning Recursion

2016-09-28 Thread Skip Cave
(}.@>@{:))) ^:3) (<20),(<2 3 4) > ┌──┬┐ > │29││ > └──┴┘ > > From here, extracting the final value of the accumulator is easy. > > None of this relies on anything special about the + verb, so this > transformation should be packageable as an adverb if you're r

Re: [Jprogramming] Learning Recursion

2016-09-28 Thread Justin R. Slepak
From: 'Pascal Jasmin' via Programming To: [email protected] Sent: Wed, 28 Sep 2016 20:34:43 -0400 (EDT) Subject: Re: [Jprogramming] Learning Recursion lispy code, as I call it, (head/rest patterns) has a bit simpler implementation than you gave (2&}. ,~ {. + {.@}.)(^:3) 20 2

Re: [Jprogramming] Learning Recursion

2016-09-28 Thread 'Pascal Jasmin' via Programming
To: [email protected] Sent: Wednesday, September 28, 2016 7:08 PM Subject: Re: [Jprogramming] Learning Recursion The tricky bit is that ^: isn't a very flexible recursion scheme. The verb it repeatedly applies effectively has to be monadic. A function on two arguments can be turned into

Re: [Jprogramming] Learning Recursion

2016-09-28 Thread Justin R. Slepak
student, Computer Science dept. - Original Message - From: Skip Cave To: [email protected] Sent: Tue, 27 Sep 2016 03:35:19 -0400 (EDT) Subject: [Jprogramming] Learning Recursion NB. I am attempting to learn recursion using ^: NB. A simple recursion: 2+^:(3) 2 8 NB. This i

Re: [Jprogramming] Learning Recursion

2016-09-27 Thread Erling Hellenäs
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.

Re: [Jprogramming] Learning Recursion

2016-09-27 Thread Raul Miller
Though, I should add, induction and recursion are very similar. There's a significant difference, though. Induction is much more like what recursive people call "tail recursion". In other words, once a function is done executing and you go on to the next function evaluation, you never come back to

Re: [Jprogramming] Learning Recursion

2016-09-27 Thread Raul Miller
^: is induction, not recursion. You should use either $: or a named routine if you want recursion. Also, ^: is defined such that the left argument is constant and the right argument is the result of the previous function evaluation. (Or, initially, the initial right argument.) Still, you can sort

[Jprogramming] Learning Recursion

2016-09-27 Thread Skip Cave
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 wa