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
2 answers

What does a continuation return in Scheme?

I came across something that I can not understand. #lang scheme (define cc #f) (define (val!) (call/cc (lambda (k) (set! cc k) 0))) (* 10 (val!)) (cc 100) So far so good; the continuation of (* 10 []) is stored in cc and if we…
user3597931
3
votes
2 answers

Forming a tree with this format in DrRacket (or Scheme)

So I am using DrRacket and have a struct defined as: (define-struct thing (a b)) Then, I have an example tree of this format: (define v (make-thing (make-thing (make-thing 1 2) (make-thing 3 4)) …
abcd
  • 33
  • 4
3
votes
1 answer

Scheme/Guile: Variable self-re-definition inside a function

I feel that understanding this subtlety might help me to understand how scope works in Scheme. So why does Scheme error out if you try to do something like: (define (func n) (define n (+ 1 n)) n) It only errors out at runtime when calling the…
ison
  • 60
  • 8
3
votes
2 answers

scheme basic loop

I'm trying to write a scheme func that behaves in a way similar to a loop. (loop min max func) This loop should perform the func between the range min and max (integers) -- one of an example like this (loop 3 6 (lambda (x) (display (* x x))…
tkcn
  • 516
  • 3
  • 10
  • 29
3
votes
1 answer

Chez Scheme: Macroexpand implementation

Does Chez Scheme offer a standard macroexpand implementation? If not, does some suitable replacement exist?
David Shaked
  • 3,171
  • 3
  • 20
  • 31
3
votes
1 answer

Scheme: using backtracking to find sentence permutations given chars list and words list

Given chars - a list of characters and words - and list of words. I wish to find all possible permutations of sentences from given words list that use all chars. For example: chars = '(i l o v e t e l e v i s i o n) words = '((i) (l o v e) (v i s i…
3
votes
2 answers

Append new item to end of list in scheme

I need to append a new item to the end of a list. Here is what I tried: (define my-list (list '1 2 3 4)) (let ((new-list (append my-list (list 5))))) new-list I expect to see: (1 2 3 4 5) But I receive: let: bad syntax (missing binding pair5s or…
Daniel H
  • 31
  • 2
3
votes
2 answers

Scheme & Smalltalk

Not really a question as such in here regarding Smalltalk and Scheme. I only started playing in Smalltalk 3 weeks ago and have been bouncing between Squeak and Pharo. Both are amazing its hard to think to me smalltalk isn't the most popular language…
sayth
  • 6,696
  • 12
  • 58
  • 100
3
votes
1 answer

map a function over a list of lists and concatenates the result into a list

How can I map a function for instance (square x) over a list of lists (list (list 1 2) (list 3 4)) and at the same time concatenates the result. For example the result would be (1 4 9 16). I can't find any detailed explanations on the web... thanks…
3
votes
1 answer

guile macro indentation in emacs

Is there something like (declare (indent defun)) for guile so indentation of user-defined macros works like defines? For example, if I write the following macro, (define-syntax my-when (syntax-rules () ((my-when condition exp ...) (if…
Rorschach
  • 31,301
  • 5
  • 78
  • 129
3
votes
1 answer

Need help understanding bindings in Scheme code

For the code below, I am unable to comprehend how the bindings (x, y, z) occur. Please check out the code, I'll explain my problem in greater detail below: (define (w x) (lambda (y z) (begin (set! x (+ (* y x) z)) x))) (define f1 (w…
Roy
  • 763
  • 2
  • 8
  • 18
3
votes
2 answers

Scheme - Iterating Over Two Lists

Hi all I am new at learning Scheme and often have issues with making parallels between an imperative language and a functional language. For example if I had had two arrays. A = [1 2 3] B = [4 5 6] If I wanted to create a new array with the…
Abdall
  • 455
  • 1
  • 6
  • 15
3
votes
1 answer

Can executable size be optimized?

I have created executable of following code in Racket (choosing Racket and not GRacket): #lang racket (print "Hello World!") It creates a tgz of 3.6 mb with an executable of 6.2 mb. This seems very large for this simplest program. Executable…
rnso
  • 23,686
  • 25
  • 112
  • 234
3
votes
2 answers

scheme how to return a form symbol + *

How can I define on scheme language this function that return if x>0 + else * like: plus_or_muliti(int x) { if (x>0) return +; else return *; } i try this and it not work on racket: (define (plus_or_multi x) (if (>= x 0) + *)) i got this…
3
votes
0 answers

How do I correctly (import (srfi :42)) in Chez scheme?

(System: centos 7, 64 bits) I am attempting to import srfi-42 into my program. This is the first srfi in Chez Scheme for me. The srfi lib is at: /home/cecilm/play/ChezScheme/chez-srfi/srfi I added this dir to my .emacs : (setenv…
Trailing Dots
  • 378
  • 1
  • 12