[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to cast an imperative loop into a readable recursive function ?
From: |
Katalin Sinkov |
Subject: |
Re: How to cast an imperative loop into a readable recursive function ? |
Date: |
Thu, 2 Dec 2010 19:03:45 -0800 (PST) |
User-agent: |
G2/1.0 |
On Dec 2, 6:17 pm, Paul Rubin <no.em...@nospam.invalid> wrote:
> Katalin Sinkov <lispstyl...@gmail.com> writes:
> > How to cast an imperative loop into a readable recursive function ?
> > What questions to ask to guide thinking to it ?
>
> The functional-programming answer is that you rarely need explicit
> recursion. You can instead usually use higher-order functions like map
> and reduce, that are defined in terms of recursion.
>
> Maybe you want to read SICP, if you haven't done so already?
>
> > Here is the concrete problem.
> > which is to find the nth character T_n in a string with erratic index
> > reset and length of substring given. ie
>
> I'm sorry, I couldn't understand the problem description.
another smaller example
s=index
v=value
series is
s=2345789
v=abcdwxy
after 5 there is 7 because there was a reset in the form
(s=7,l=whatever)
(s=2,l=4)2345(s=7,l=whatever)
only start index of the subseries is mentioned inside parens.
hope it was clear, or i can try again
Re: How to cast an imperative loop into a readable recursive function ?, RG, 2010/12/09