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 19:30:00 -0800 Organization: Nightsong/Fort GNOX Message-ID: <7xfwufmt3b.fsf@ruckus.brouhaha.com> References: <7xmxontxan.fsf@ruckus.brouhaha.com> <8a5ef1e1-aab3-47bd-80e3-081f8dc65b0e@c39g2000yqi.googlegroups.com> <84a24d31-6379-4b81-ac65-b0d8642ab7da@37g2000prx.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1291956075 10344 80.91.229.12 (10 Dec 2010 04:41:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Dec 2010 04:41:15 +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:11 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 1PQun9-0001h3-FC for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Dec 2010 05:41:11 +0100 Original-Received: from localhost ([127.0.0.1]:57034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQuek-0007k9-VZ for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 23:32:31 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.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:b3ivYvvi0r8WCIXI/OIqEn/X43U= Original-Lines: 15 Original-NNTP-Posting-Date: 02 Dec 2010 21:30:06 CST Original-X-Complaints-To: abuse@octanews.net Original-Xref: usenet.stanford.edu comp.lang.lisp:296044 comp.emacs:100890 gnu.emacs.help:182795 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:77333 Archived-At: Katalin Sinkov writes: > what I forgot to mention was that it should be possible to view the > subseries problem in a way that I dont have to go thru a loop but use > recursive definitions. The problem is still very confusing, but it sounds to me like maybe you want something like (untested): (defun foo (n str) (let ((s ...) (l ...) (p ...) ;; after reading the (s=2 l=4) prefix above, ;; p points past the end of it (if (< n l) (aref str (+ p n)) (foo (- n l) (substring str (+ p l)))))))