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

Advantages of different Scheme R6RS implementations

I'd like to start programming in Scheme but the variety of different implementations is confusing. What are some advantages or disadvantages of various implementations?
Jeremy
  • 1
  • 85
  • 340
  • 366
3
votes
1 answer

Implementing powerset in scheme

I am trying to implement a powerset function in Scheme in two ways. One way is using tail recursion, and I did it like this: (define (powerset list) (if (null? list) '(()) ;; if list is empty, its powerset is a…
avish12
  • 107
  • 8
3
votes
1 answer

Scheme procedure with 2 arguments

Learned to code C, long ago; wanted to try something new and different with Scheme. I am trying to make a procedure that accepts two arguments and returns the greater of the two, e.g. (define (larger x y) (if (> x y) x (y))) (larger 1…
h34thf
  • 33
  • 1
  • 4
3
votes
2 answers

How to load a huge file into a String or list in Racket?

I have a HUGE file that I need to do operations on. Huge as in approx. half a million words. I just want to read it into a list or String so I can do things with it later. Also I know I could load it into a string using file->string OR use…
Monny Star
  • 83
  • 6
3
votes
1 answer

random function in scheme

I am trying to get a random string from a list of strings in scheme. Example List ( "this" "that" "today" "yesterday") So based on length of the list a random number is created and that word is output. But keep getting error! I tried it like…
JJunior
  • 2,831
  • 16
  • 56
  • 66
3
votes
2 answers

Do iterative loop in scheme

New to scheme here and I'm having some trouble learning do loops. I am attempting to make a function that will take in an object and a vector, and then iterate through the vector until it find that object. When the object is found, it would then…
cliff259
  • 114
  • 2
  • 9
3
votes
1 answer

Why is my cubic root algorithm wrong? Exercise 1.8 in SICP

> Fixed, it was not a huge number but a fraction of two huge numbers, so I got a false alarm. The algorithm was right; modifying the last input parameter now the interpreter retrieves it as a decimal comma, and looks like the small number it…
3
votes
3 answers

Scheme - Unbound variable: unquote

I am new to Scheme; I am writing a program that recursively defines multiplication in terms of repeated addition: (define multiply (lambda (a b) (if (= b 0) 0 (+ a (multiply(a, (- b 1))))))) However, when I attempt to run…
3
votes
1 answer

Value returned by a define expression in Scheme

I ran this in MIT/GNU Scheme: (define x (+ 2 3)) The interpreter then prints: ;Value: x But according to my textbook, the value returned by a define expression should be undefined. Why did the interpreter print ";Value: x" then?
Flux
  • 9,805
  • 5
  • 46
  • 92
3
votes
2 answers

How do you sum numbers in a list of structs? (Racket)

I'm trying to sum all integers in a list of structs using a recursive function but cannot for the life of me figure it out. (struct number (int)) (define ints (list (number 1) (number 2) (number 3))) (define…
j.doe
  • 1,214
  • 2
  • 12
  • 28
3
votes
2 answers

Racket Function with Two Arguments

I'm trying to review my final exam in R5RS, but having trouble with a simple problem. My professor isn't really helpful and I don't know anybody in my class. Can you help me? The function ratio takes in two parameters f (function) and x (a number).…
Laura
  • 31
  • 2
3
votes
1 answer

how to write Collatz sequence using unfold in scheme/racket?

After writing the Collatz sequence generating function the regular way: (define (colatz-seq #;starting@ n) (cond ((= n 1) '()) ((even? n) (cons (/ n 2) (colatz-seq (/ n 2)))) ((odd? n) (cons (+ (* n 3) 1) (colatz-seq (+ (* n 3)…
X10D
  • 600
  • 2
  • 13
3
votes
2 answers

Is there any way to make a lat using cons in scheme?

I'm having this simple piece of code, constructing a list of numbers: #lang scheme (define pseudofizzbuzz (lambda (x) (cond ((zero? x) (quote ())) ((or (integer? (/ x 3)) (integer? (/ x 5))) (cons (quote…
3
votes
3 answers

Smallest element in a list using higher-order functions

I am trying to find the smallest element in a list of numbers. This is trivial when using explicit recursion, but I am looking for a way to do this using solely the built-in higher-order functions, like map, filter, and foldr. In other words, I…
Swifty
  • 839
  • 2
  • 15
  • 40
3
votes
1 answer

The order of growth of the Fermat test in SICP

The fermat-test procedure presented by Structure and Interpretation of Computer Programs has a theta-of-log(n) order of growth, which has been verified by me and many other people's experiments. What confuses me is the random primitive procedure in…
nalzok
  • 14,965
  • 21
  • 72
  • 139