1 Replies - 2793 Views - Last Post: 03 October 2008 - 01:53 AM

#1 LowWaterMark  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 119
  • Joined: 30-July 08

Recursion in Scheme

Post icon  Posted 29 September 2008 - 11:54 PM

A couple days back I posted a problem in the "Other Languages" forum at:
http://www.dreaminco...wtopic65339.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.

Is This A Good Question/Topic? 0
  • +

Replies To: Recursion in Scheme

#2 LowWaterMark  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 119
  • Joined: 30-July 08

Re: Recursion in Scheme

Posted 03 October 2008 - 01:53 AM

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

(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:

Posted Image

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

(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.dreaminco...wtopic65339.htm
for full explanation of my dilemma.

This post has been edited by LowWaterMark: 03 October 2008 - 01:58 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1