the-little-schemer

What is ' (apostrophe) in Lisp / Scheme?

自闭症网瘾萝莉.ら 提交于 2019-12-02 19:55:47
I am on day 1 hour 1 of teaching myself Scheme. Needless to say, I don't understand anything. So I'm reading The Little Schemer and using this thing: http://sisc-scheme.org/sisc-online.php as an interpreter. I need to use ' in for example (atom? 'turkey) to avoid an "undefined variable" error. The ' , according to the book, is a Common Lisp thing. I have two questions: Is the interpreter I mentioned above a good one? Can you recommend another? I need one that will go well with The Little Schemer . What is ' ? The form 'foo is simply a faster way to type the special form (quote foo) which is to

How to do this length≤1 more than once?

大憨熊 提交于 2019-12-02 03:22:39
问题 I've spent a day reading page 166's length≤1 in the book The Little Schemer ; there's the following code: (((lambda (mk-length) (mk-length mk-length)) (lambda (mk-length) (lambda (l) (cond ((null? l) 0) (else (add1 ((mk-length eternity) (cdr l)))))))) l) where l is (apples) and eternity is as follows: (define eternity (lambda (x) (eternity x))) Page 166 (4th ed.) states that: When we apply mk-length once, we get length≤1 And then Could we do this more than once? But I do not know how to do

mini-kanren what is the difference between cond-a cond-u and cond-e?

半城伤御伤魂 提交于 2019-12-01 06:36:38
I have tried to use an implementation of mini-kanren in clojure. But been struggling to understand the difference between cond-a cond-u and cond-e. I seem to be quite clear about cond-e but understanding of cond-a and cond-u is quiet bad. cond-e takes a set of goals and then tries each of them... i.e tries all the branches that succeed. cond-a and cond-u on the contrary commit to the branch whose first predicate succeeds and cond-a returns all the possible successful unifications there after. while cond-u returns only the first successfull unification ... but however it seems like this

mini-kanren what is the difference between cond-a cond-u and cond-e?

余生颓废 提交于 2019-12-01 05:54:40
问题 I have tried to use an implementation of mini-kanren in clojure. But been struggling to understand the difference between cond-a cond-u and cond-e. I seem to be quite clear about cond-e but understanding of cond-a and cond-u is quiet bad. cond-e takes a set of goals and then tries each of them... i.e tries all the branches that succeed. cond-a and cond-u on the contrary commit to the branch whose first predicate succeeds and cond-a returns all the possible successful unifications there after.

The Little Schemer evens-only*&co

眉间皱痕 提交于 2019-11-30 06:51:27
I'm having difficulty understanding what's going on with The Little Schemer's evens-only*&co example on page 145. Here's the code: (define evens-only*&co (lambda (l col) (cond ((null? l) (col '() 1 0)) ((atom? (car l)) (cond ((even? (car l)) (evens-only*&co (cdr l) (lambda (newl product sum) (col (cons (car l) newl) (opx (car l) product) sum)))) (else (evens-only*&co (cdr l) (lambda (newl product sum) (col newl product (op+ (car l) sum))))))) (else (evens-only*&co (car l) (lambda (newl product sum) (evens-only*&co (cdr l) (lambda (dnewl dproduct dsum) (col (cons newl dnewl) (opx product

Little Schemer and Racket

巧了我就是萌 提交于 2019-11-28 18:47:48
I'm starting to read the Little Schemer and now instead of PLT Scheme we have Racket. I would like to know if Racket is suitable for doing the exercises in the book or do I need to get another true Scheme compiler. Before I forgot to tell you, my OS is Windows x64. The book, language and paradigm is complex enough, I would love to avoid struggling with a compiler. Thanks a lot in advance. DrRacket is the (r)evolution of DrScheme; DrRacket will work perfectly for the exercises in "The Little Schemer". Just don't forget to: In the Language dialog, choose "Use the language declared in the source"

Explain the continuation example on p.137 of The Little Schemer

南楼画角 提交于 2019-11-28 05:31:02
The code in question is this: (define multirember&co (lambda (a lat col) (cond ((null? lat) (col (quote ()) (quote ()))) ((eq? (car lat) a) (multirember&co a (cdr lat) (lambda (newlat seen) (col newlat (cons (car lat) seen))))) (else (multirember&co a (cdr lat) (lambda (newlat seen) (col (cons (car lat) newlat) seen)))))) I've stared at this all day but I can't quite seem to understand it. When you recur on the function you are re-defining col but in the examples they seem to use the original definition. Why wouldn't it change. How can you recur on it without passing in the parameters newlat

Little Schemer and Racket

纵饮孤独 提交于 2019-11-27 20:24:03
问题 I'm starting to read the Little Schemer and now instead of PLT Scheme we have Racket. I would like to know if Racket is suitable for doing the exercises in the book or do I need to get another true Scheme compiler. Before I forgot to tell you, my OS is Windows x64. The book, language and paradigm is complex enough, I would love to avoid struggling with a compiler. Thanks a lot in advance. 回答1: DrRacket is the (r)evolution of DrScheme; DrRacket will work perfectly for the exercises in "The

Explain the continuation example on p.137 of The Little Schemer

谁说我不能喝 提交于 2019-11-27 00:47:31
问题 The code in question is this: (define multirember&co (lambda (a lat col) (cond ((null? lat) (col (quote ()) (quote ()))) ((eq? (car lat) a) (multirember&co a (cdr lat) (lambda (newlat seen) (col newlat (cons (car lat) seen))))) (else (multirember&co a (cdr lat) (lambda (newlat seen) (col (cons (car lat) newlat) seen)))))) I've stared at this all day but I can't quite seem to understand it. When you recur on the function you are re-defining col but in the examples they seem to use the original

Y combinator discussion in “The Little Schemer”

佐手、 提交于 2019-11-26 21:33:12
So, I've spent a lot of time reading and re-reading the ending of chapter 9 in The Little Schemer , where the applicative Y combinator is developed for the length function. I think my confusion boils down to a single statement that contrasts two versions of length (before the combinator is factored out): A: ((lambda (mk-length) (mk-length mk-length)) (lambda (mk-length) (lambda (l) (cond ((null? l) 0 ) (else (add1 ((mk-length mk-length) (cdr l)))))))) B: ((lambda (mk-length) (mk-length mk-length)) (lambda (mk-length) ((lambda (length) (lambda (l) (cond ((null? l) 0) (else (add1 (length (cdr l)