Questions tagged [scheme]

Scheme is a functional programming language in the Lisp family, closely modeled on lambda calculus with eager (applicative order) evaluation. FOR questions about URL schemes PLEASE use the tag "URL-scheme".

Scheme is a functional programming language. It is designed to provide a mathematically well-founded language based on lambda calculus (with eager evaluation).

It follows a minimalist design philosophy specifying a small standard core with powerful tools for language extension. Its compactness and elegance have made it popular with educators, language designers, programmers, implementors, and hobbyists.

The Scheme language belongs to the Family. Since Scheme uses a single namespace for naming functions and other values, it is called a lisp-1.

Over the years, attempts at standardizing Scheme have been made including the R5RS standard, the somewhat controversial R6RS, and the most recent standard R7RS which is attempting to split the language into small and large (ongoing) standards.

Free Scheme Programming Books

Implementations

Community Websites

8110 questions
22
votes
1 answer

Can `match` in Racket have patterns with variables from an outer scope?

Consider the following example: #lang racket (match '(cat . doge) [`(,a . ,b) (match b [a #t] [_ #f])] [_ "Not a pair"]) This is what I might write if I wanted to match pairs where the head and tail are the same. This doesn't work…
Chris Brooks
  • 725
  • 6
  • 15
22
votes
3 answers

What is the difference between map and apply in scheme?

I am trying to learn Scheme and I am having a hard time understanding the difference between map and apply. As I understand, map applies the function to each element of the list, and apply applies something to the arguments of a procedure. Can they…
Sarah
  • 2,713
  • 13
  • 31
  • 45
22
votes
5 answers

small & readable scheme interpreter in C++?

Anyone know of a good / small scheme interpreter in C++? Perferably something < 2000 LOC, with a simple garbage collectro (either compacting or mark & sweep), no need to support all of R5RS, just basics of if/lambda/set!/cons/car/cdr and some basic…
anon
  • 41,035
  • 53
  • 197
  • 293
22
votes
4 answers

Why doesn't a primitive `call-with-current-continuations` exist in Common Lisp

Scheme offers a primitive call-with-current-continuation, commonly abbreviated call/cc, which has no equivalent in the ANSI Common Lisp specification (although there are some libraries that try to implement them). Does anybody know the reason why…
Paulo Tomé
  • 1,910
  • 3
  • 18
  • 27
22
votes
4 answers

How do I get the type of a value in Scheme?

I want a function that gets the type of a value at runtime. Example use: (get-type a) where a has been defined to be some arbitrary Scheme value. How do I do this? Or do I have to implement this myself, using a cond stack of boolean?, number?…
Matt Fenwick
  • 48,199
  • 22
  • 128
  • 192
21
votes
3 answers

set-car!, set-cdr! unbound in racket?

I am just trying to do very simple code with set-car! and set-cdr! in racket, but I got the error: expand: unbound identifier in module in: set-car! and expand: unbound identifier in module in: set-cdr! Aren't they defined in racket? Could anyone…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
21
votes
16 answers

Python Macros: Use Cases?

If Python had a macro facility similar to Lisp/Scheme (something like MetaPython), how would you use it? If you are a Lisp/Scheme programmer, what sorts of things do you use macros for (other than things that have a clear syntactic parallel in…
Rick Copeland
  • 11,672
  • 5
  • 39
  • 38
21
votes
7 answers

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

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…
nweiler
  • 1,140
  • 1
  • 13
  • 23
21
votes
3 answers

What are some good ways of implementing tail call elimination?

I've written a small Scheme interpreter in an unholy mix of C/C++, but I have yet to implement proper tail calls. I am aware of the classic Cheney on the MTA algorithm, but are there other nice ways of implementing this? I know I could put the…
csl
  • 10,937
  • 5
  • 57
  • 89
21
votes
8 answers

How to undefine a variable in Scheme?

How to undefine a variable in Scheme? Is this possible?
eonil
  • 83,476
  • 81
  • 317
  • 516
21
votes
12 answers

Looking for examples of "real" uses of continuations

I'm trying to grasp the concept of continuations and I found several small teaching examples like this one from the Wikipedia article: (define the-continuation #f) (define (test) (let ((i 0)) ; call/cc calls its first function argument,…
21
votes
13 answers

Would Lisp be extremely difficult for a new(ish) programmer to learn?

I've got a little experience with Python (enough to where I can do if/else/elif and some random number generation), but I've always had a weird fascination with the Lisp languages. I downloaded some scheme source code to look at the syntax but it…
Rubber Duchy
  • 259
  • 1
  • 2
  • 3
21
votes
3 answers

What is "Call By Name"?

I'm working on a homework assignment where we are asked to implement an evaluation strategy called "call by name" in a certain language that we developed (using Scheme). We were given an example in Scala, but I don't understand how "call by name"…
forellana
  • 937
  • 1
  • 8
  • 19
21
votes
3 answers

SICP example: Counting change, cannot understand

I am a beginner following SICP course on MIT OpenCourseWare using both the video lectures and the book available online. Yesterday I came across an example, which ask if we can write a procedure to compute the number of ways to change any given…
nonameable
  • 426
  • 3
  • 11
21
votes
4 answers

The Little Schemer - Where to start?

I just cracked open The Little Schemer, and I feel like I'm missing something. The first question asks "Is it true that this is an atom?", but I do not see any definition of what an atom is. I suppose I can derive what an atom is by the answers…