From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Rubin Newsgroups: gmane.emacs.help Subject: Re: How to cast an imperative loop into a readable recursive function ? Date: Thu, 02 Dec 2010 18:17:20 -0800 Organization: Nightsong/Fort GNOX Message-ID: <7xmxontxan.fsf@ruckus.brouhaha.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1291956118 10502 80.91.229.12 (10 Dec 2010 04:41:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Dec 2010 04:41:58 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 10 05:41:55 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQunp-0001h3-9K for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Dec 2010 05:41:53 +0100 Original-Received: from localhost ([127.0.0.1]:59911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQuaT-0005Pb-2b for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 23:28:05 -0500 Original-Path: usenet.stanford.edu!news.glorb.com!news2.glorb.com!news.glorb.com!news-out.octanews.net!indigo.octanews.net!auth.beige.octanews.com.POSTED!not-for-mail Original-Newsgroups: comp.lang.lisp,comp.emacs,gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:AGwBXyl5P/S7ysipKhVF4Eu53pM= Original-Lines: 15 Original-NNTP-Posting-Date: 02 Dec 2010 20:17:26 CST Original-X-Complaints-To: abuse@octanews.net Original-Xref: usenet.stanford.edu comp.lang.lisp:296033 comp.emacs:100883 gnu.emacs.help:182787 X-Mailman-Approved-At: Thu, 09 Dec 2010 20:09:07 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:77338 Archived-At: Katalin Sinkov 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.