Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,360 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,260 people online right now. Registration is fast and FREE... Join Now!




Recursion in Scheme

 
Reply to this topicStart new topic

Recursion in Scheme

LowWaterMark
post 29 Sep, 2008 - 10:54 PM
Post #1


D.I.C Head

**
Joined: 30 Jul, 2008
Posts: 119



Thanked 1 times
My Contributions


A couple days back I posted a problem in the "Other Languages" forum at:
http://www.dreamincode.net/forums/showtopic65339.htm

Unfortunately I haven't gotten any response. It my be in the wrong place as it its subject lies between algorithms (Computer Science) and Scheme (Other Languages).

I'm still struggling here on day three, so this is just a crier's call for assistance. I would of moved it if I could. I didn't want to copy the whole thing here and get a stinging rebuke from the moderators.

Please, if you are fluent in Scheme and intuitively understanding of recursion, take a look at my above link.
User is offlineProfile CardPM

Go to the top of the page

LowWaterMark
post 3 Oct, 2008 - 12:53 AM
Post #2


D.I.C Head

**
Joined: 30 Jul, 2008
Posts: 119



Thanked 1 times
My Contributions


Scouts honor - I'm not trying to get someone to explain recursion. For example:

CODE
(define factorial
    (lambda (n)
    (cond
    ((or (< n 0) (null? n)) (quote ()))
      (else
      ((cond (= n 0) 1)
          (else * n (factorial (- n 1))))))


>factorial 3

will execute a recursive send/return something like:

IPB Image

I do intuitively understand simple recursion. What I don't get is recursion within a recursion, as in my OP:

CODE
(define rember
   (lambda(a lat)
       (cond
          ((null? lat) (quote ()))
          ((eq? (car lat) a) (cdr lat))
          (else (cons (car lat)
                     (rember a (cdr lat)))))))


where argument:
a is and
and
lat is (bacon lettuce and tomato)

Please refer to my OP at:
http://www.dreamincode.net/forums/showtopic65339.htm
for full explanation of my dilemma.

This post has been edited by LowWaterMark: 3 Oct, 2008 - 12:58 AM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 04:51AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month