Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The Little Schemer

Name: Anonymous 2009-07-19 23:23

Hi, I am working through the little schemer. I do not have the math skills to work through SICP.

I have the following code:


(define (member? a lat)
  (lambda (a lat)
    (cond
      ((null? lat) #f)
      (else (or (eq? (car lat) a)
                (member? a (cdr lat)))))))



When I run this say like:
(member? 3 (cons 3 '(9 8 7 6 13 3)))

I get the following:
#<procedure:...my-scheme-log.ss:137:2>
rather than a list without the first instance of 3

Can you help me?

Name: Anonymous 2009-07-20 0:05

>>2
Thank you. I see what you are saying. In one expression, lambda is the argument to foo where as lambda anything is just a standalone lambda expression (i.e. anonymous function) like python's lambda.

So when I ran this I was seeing the result of the return of the (lambda ...) portion rather than the top level definition.


Hey, this is pretty cool. I like scheme. This is my first functional language and I like it so far.

Thanks >>2! I appreciate the help.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List