Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!snorkelwacker.mit.edu!ai-lab!zurich.ai.mit.edu!markf From: markf@zurich.ai.mit.edu (Mark Friedman) Newsgroups: comp.lang.scheme Subject: Re: Scheme recursive procedures Message-ID: Date: 1 Feb 91 17:02:06 GMT References: <9102010942.aa25019@mc.lcs.mit.edu> Sender: news@ai.mit.edu Reply-To: markf@zurich.ai.mit.edu Organization: M.I.T. Artificial Intelligence Lab. Lines: 32 In-reply-to: jar@altdorf.ai.mit.EDU's message of 1 Feb 91 14:40:47 GMT In article <9102010942.aa25019@mc.lcs.mit.edu> jar@altdorf.ai.mit.EDU (Jonathan A Rees) writes: The following is from John Allen's book _Anatomy of Lisp_, if I recall correctly (unlikely): (define (reverse l) (cond ((null? l) l) ((null? (cdr l)) l) (else (cons (car (reverse (cdr l))) (reverse (cons (car l) (reverse (cdr (reverse (cdr l)))))))))) Somehow I don't think this is what you had in mind, but I'm sure that other members of this forum will supply you with plenty of alternatives. You remembered correctly. In defence of John Allen, the above definition was presented in his book after the version with a helper function and after the append version. He wanted to show that "it is possible to write a directly recursive reversing funtion with no auxiliary fuctions, no functions other than the primitives, and with not much clarity." -Mark -- Mark Friedman MIT Artificial Intelligence Lab 545 Technology Sq. Cambridge, Ma. 02139 markf@zurich.ai.mit.edu