[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: |
Paul Rubin |
Subject: |
Re: How to cast an imperative loop into a readable recursive function ? |
Date: |
Thu, 02 Dec 2010 18:17:20 -0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Katalin Sinkov <lispstylist@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.
Re: How to cast an imperative loop into a readable recursive function ?, RG, 2010/12/09