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
3
votes
3 answers

Confused by let to lambda conversion

I am currently, going through this great article on Y-combinator by Mike Vanier. Along the explanation the following line is dropped: It turns out that any let expression can be converted into an equivalent lambda expression using this…
user8554766
3
votes
1 answer

Pushing item locations in Casting SPELs

I'm going through Casting SPELs in Lisp and this is the proposed solution to handling picking up objects: (define *location* 'living-room) (define *object-locations* '((whiskey-bottle living-room) (bucket living-room) (chain garden) …
Philip Seyfi
  • 929
  • 1
  • 10
  • 24
3
votes
2 answers

gimp script-fu: drawing a simple line

I'm trying to draw a line using gimp scripting. In the following script: I create a new image 512x512 and a I try to draw a diagonal (0,0)->(512,512). But the image (tmp.xcf) remains transparent. What am i doing wrong ? (define (drawdiagonal W…
Pierre
  • 34,472
  • 31
  • 113
  • 192
3
votes
1 answer

Understanding the environment model of evaluation

Exercise 3.20 in SICP: Draw environment diagrams to illustrate the evaluation of the sequence of expressions (define x (cons 1 2)) (define z (cons x x)) (set-car! (cdr z) 17) (car x) 17 using the procedural implementation of pairs given…
lightning_missile
  • 2,821
  • 5
  • 30
  • 58
3
votes
1 answer

GUI in DrRacket running slow on laptop (low FPS)

for a project i have to remake the game "Donkey Kong", i have done most of it, but for some reason the game is slow "laggy" on my gaming laptop (10-40 FPS). On my desktop computer it runs fine (+100fps). Is there a way i can fix this? The processor…
KillerZ224
  • 41
  • 2
3
votes
3 answers

Function which returns all values associated with a symbol

For example, I want a function that gives me all the values assigned to the one I give: -> (giveme 'x '((x y) (x z) (b d) (x q))) -> (y z q) So the function should return in this case y z and q, as these are associated to x in pairs. Reason I ask…
user461316
  • 893
  • 3
  • 12
  • 31
3
votes
2 answers

Racket eof-object read from input port

I tried to read string from an input-port in Racket, but no matter what API functions I used to read (read, read-string, read-bytes etc), the return value of those functions was never equal eof-object. (define (some_process inp) (begin (let ([c…
user618815
3
votes
1 answer

Scheme - Working with List of Lists

Currently for an assignment I'm working on a scheme problem where we are representing a graph using scheme lists. The first variation we are using is an edge-list graph represented as '((x y) (y z) (x z)) The second variation of the graph we are…
nwelch
  • 89
  • 7
3
votes
3 answers

backquote, unquote and unquote-splicing in normal functions

I am still in the process of understanding macros and though I think I understand the basics of "backquote" "unquote" and "unquote splicing", I had thought they were only used/useful in macros. however I came across this Common Lisp code from…
Kyuvi
  • 360
  • 3
  • 13
3
votes
3 answers

sum of a list in scheme

I'm beginner in functional programming and scheme language. I found a way to build the sum of a list: (define (sum lst) (if (empty? lst) 0 (+ (car lst) (sum (cdr lst))))) (sum (list 1 2 3)) My question is: is there a way to build the…
Serge
  • 41
  • 1
  • 3
3
votes
2 answers

Creating a list of n elements in Scheme/lisp?

I am trying to create a list of n elements. It must produce this output: (my-list 5) >> 0 1 2 3 4 I have the function below: (define (my-list n) (cond ((<= n 0) '()) (else (reverse-list (cons (- n 1) …
Kattie.S
  • 117
  • 1
  • 11
3
votes
2 answers

How do I evaluate a symbol in MIT Scheme?

I have a following in Scheme: ((car '(null? null?)) ()) which should evaluate to #t but I'm getting an error: the object null? is not applicable I tried some of the solutions in other SO questions but none of them seems to work. How do I evaluate…
JJTO
  • 847
  • 2
  • 8
  • 13
3
votes
1 answer

What is the difference between these macros?

I have some questions about how macros work in Scheme (specifically in Chicken Scheme), let's consider this example: (define (when-a condition . body) (eval `(if ,condition (begin ,@body) '()))) (define-syntax when-b …
Andrea Ciceri
  • 436
  • 6
  • 16
3
votes
1 answer

Examples to show how to use Racket lexer generator?

I am playing with the Racket recently, currently implementing a lexer for a subset of scripting language...and wondering whether there are more examples to show how to use the lexer generator in Racket? I understand the calculator example in the…
user618815
3
votes
1 answer

bad syntax trying to define a local inside a block

So I have the following code block in Racket/Scheme: (define (inc x) (local (define a 1) (+ x a))) And when I try to run it or check syntax (in Dr. Racket) on it I get the following error: define: bad syntax in: define I know it's probably…
alesplin
  • 1,332
  • 14
  • 23