Questions tagged [the-little-schemer]

**The Little Schemer**, a book on recursive programming by Daniel P. Friedman and Matthias Felleisen

The Little Schemer (original title: The Little Lisper) is a book by Daniel P. Friedman and Matthias Felleisen, designed to introduce the principles of recursive programming to an audience who may have no prior experience of programming or mathematics. All the examples are in the Scheme language but it is not intended as an introduction to Scheme (although it is based on lecture notes from an "Introduction to Scheme" mini course) and only uses that subset of the language necessary to implement solutions to the various tasks set in the book.

67 questions
1
vote
3 answers

Scheme: Is it possible to convert a list of S-expressions into a list of atoms?

I am trying to convert a list of S-expressions to a plain list of atoms similar to a problem in the book The Little Schemer. My code is (as typed in Dr.Racket): > (define lat '((coffee) cup ((tea) cup) (and (hick)) cup)) > (define f (lambda…
Sreekumar R
  • 573
  • 6
  • 24
1
vote
3 answers

Does a non-null Scheme list contain at least one atom?

In The Little Schemer (4th Ed.) it is claimed that a list for which null? is false contains at least one atom, or so I understand from my reading of the text. This doesn't make sense to me, since (atom '()) is false, and we can stick those into a…
1
vote
1 answer

Certain functions not loading into repl

Working through Little Schemer, We're required to define a few of our own functions. I've defined them, only add1 and sub1 appear in the repl after it loads. I'm using Racket v7.0. #lang racket …
1
vote
2 answers

[Little Schemer Ch3 pp.34 & 37]: Why (rember a (cdr lat)) as the 2nd argument of cons interpreted as unknown on p.37 example

I run both example on p.34 and p.37 using DrRacket debug mode step by step. And below are the stack windows results when processing (cdr lat) the first time of both examples. p.34, the failed example without cons (define rember (lambda (a lat) …
1
vote
1 answer

The Little Schemer: `lat?` without `cond`?

One of the first questions in the second chapter of The Little Schemer (4th edition) asks the reader to write the function lat?, where (lat? l) returns true if l is a list of atoms. It goes on to say: You were not expected to be able to do this…
1
vote
1 answer

Determining if a number is negative in Scheme with one function

I have been going through The Little Schemer and I started getting curious about how to deal with negative numbers. It seemed like a nice challenge to figure out how to build a function to determine if a number is negative or positive. So far I…
grossmae
  • 331
  • 5
  • 16
1
vote
0 answers

Little Schemer - IDE

I am reading through the book "The Little Schemer" and looking for an IDE that allows me to play with the code in the book. I have looked at DrRacket and REPL, but not sure if these are the best IDEs for this learning goal. Also - is there any…
user1885116
  • 1,757
  • 4
  • 26
  • 39
1
vote
2 answers

Little Schemer "S-expression" predicate

Is it true that this is an S-expression? xyz asks The Little Schemer. but how to test? syntactically, i get how to test other statements like > (atom? 'turkey) and > (list? '(atom)) not entirely sure how to test this... > (list? '(atom turkey)…
1
vote
2 answers

The little schemer - semantic

I have just started reading The Little schemer. I have some problem understanding some words. In page 27 it says, The Law of Eq? The primitive eq? takes two arguments. Each must be a non-numeric atom." And a footnote says: In practice, some…
Shakil Ahamed
  • 587
  • 3
  • 18
1
vote
1 answer

Best Scheme implementation for Emacs and The Little Schemer?

I've tried Geiser and I keep getting this error message: Unable to start REPL: Searching for program: permission denied, guile.exe I'm on Windows 7 by the way. Also, here's my Geiser path in my .emacs: (load-file…
1
vote
2 answers

Returning functions in scheme

I have been playing about with The Little Schemer, and am trying ideas as i work through (not all of which are working out). Just now, i am in Chapter 6 (where they introduce helper functions) and i feel that a step is within reach -- i just don't…
ricardo
  • 8,195
  • 7
  • 47
  • 69
1
vote
1 answer

Scheme if-statement

I'm currently studying Scheme with The Little Schemer and ran into an odd trouble. Here is my code: (define rember (lambda (a lat) ((if (null? lat) '() (cond ((eq? a (car lat)) (cdr lat)) (else (rember…
babel92
  • 767
  • 1
  • 11
  • 21
1
vote
3 answers

what is the difference between these two Scheme functions?

(define self-add (let ((x 0)) (lambda () (set! x (+ x 1)) x))) (self-add) => 1 (self-add) => 2 (self-add) => 3 (self-add) => 4 2. (define self-add1 (lambda () (let ((x 0)) (set! x (+ x 1)) …
abelard2008
  • 1,984
  • 1
  • 20
  • 35
0
votes
2 answers

In Scheme, what is the difference between `nil` and `null`?

In "The Little Schemer", null is used to refer to the empty list (). But I also see the empty list referred to as nil in Scheme's Error message, e.g. doing: (car ()) causes: Error: Attempt to apply car on nil [car] [1] Which sounds like it's…
joseville
  • 685
  • 3
  • 16
0
votes
1 answer

Ambiguity with `quote` in the Little Schemer. When should an expression be proceeded with a quote and when shouldn't it?

The Little Schemer 4e by Friedman and Felleisen starts out by defining atom?: (define atom? (lambda (x) (and (not (pair? x)) (not (null? x))))) Then in the first chapter there's questions asking if so and so is a atom or not. E.g. (the…
joseville
  • 685
  • 3
  • 16