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

storing values in Scheme globally

I have a series of mathmetical operations I need to perform. The input of the function is n. the first two operations are summations. using n. The result needs stored as a variable to be used in later functions. ex. main func(n) func1…
DJPlayer
  • 3,244
  • 2
  • 33
  • 40
3
votes
1 answer

Do linked lists have a practical performance advantage in eager functional languages?

I'm aware that in lazy functional languages, linked lists take on generator-esque semantics, and that under an optimizing compiler, their overhead can be completely removed when they're not actually being used for storage. But in eager functional…
lcmylin
  • 2,552
  • 2
  • 19
  • 31
3
votes
1 answer

Cleanest way to make a "derived" identifier?

It's very common for Scheme macros to make "derived" identifiers, like how defining a record type foo (using the R6RS syntactic record API) will by default define a constructor called make-foo. I wanted to do something similar in my own macro, but I…
lcmylin
  • 2,552
  • 2
  • 19
  • 31
3
votes
2 answers

Find how many times each number occurs in list

If we had a list A holding (1 2 1 1 2 3 3 4 4 4), how could we get a new list B with ((1 . 30) (2 . 20) (3 . 20) (4 . 30)) in it, such that the number_after_dot is the percentage of the number_before_dot in the list A. For example 1 is 30% of list…
bpavlov
  • 1,080
  • 12
  • 32
3
votes
2 answers

Racket: How to write foldl using foldr

I'm currently preparing for an exam and thought that writing foldl with foldr would be a nice question to get tested on. Anyways, I know that (foldl f base lst) returns (f xn (f x(n-1) . . . (f x1 base) with the lst being (x1 . . . xn) So what I…
Syn F G
  • 33
  • 3
3
votes
1 answer

Coding an approximation sequence recursively. DrRacket, Scheme

Very recently, a question was asked, "How to find mistake in my sequence. DrRacket, Scheme", and then deleted by an impatient asker. Since I was in the process of typing the very few last words of my answer, here it is reposted, the Q and the A, so…
Will Ness
  • 70,110
  • 9
  • 98
  • 181
3
votes
6 answers

How to create a function that makes a list that contains 1,2,3,4,5... to n in Scheme

I am trying to learn Scheme, and I encounter a problem. I am able to make a recursive function to create a list like (5,4,3,2,1). But I don't know how to create a function (let's say (define (make_list n)) ) that has ascending order of elements…
KamiGasai
  • 43
  • 4
3
votes
5 answers

Declare a function with no return value?

Can we create a function with void (i.e with no return value) in functional languages? Like Haskell or Scheme
Jeff Yan
  • 309
  • 1
  • 3
  • 9
3
votes
3 answers

Racket count occurrences using `map`

Write a Racket function count-occurrences that consumes two lists of symbols and produces a list of natural numbers measuring how many times items in the first list occur in the second list. For example: (count-occurrences (list 'a 'b 'a 'q)…
Alice Song
  • 41
  • 4
3
votes
1 answer

how to give a number a leading zero in scheme

How do you give a number a leading zero in scheme language? For instance, I want the time to give 09:05 AM with a leading zero in front of the 9 and 5, instead of having 9:5 AM.
M.Maric
  • 57
  • 8
3
votes
1 answer

Idiomatic usage of local vs lambda?

In Exercise 30.1.1 of HtDP, I started off using local and then modified it to use lambda in order to answer the question. (define (add-to-each2 accu a-list) (cond [(empty? a-list) empty] [else (local ((define s (+ accu (first a-list)))) …
Greenhorn
  • 411
  • 1
  • 6
  • 14
3
votes
2 answers

Order of the evaluation of lambda expressions in Scheme

Dr. Racket user. Here are two expressions: ((lambda(x)(+ x 1))3) ((lambda(x)(+ x 1)2)3) The first is a lambda expression that takes one input and increases it by 1. So it takes 3 as its operand and makes (lambda(3)(+ 3 1) which is equal to 4. The…
Dmitrii
  • 173
  • 7
3
votes
1 answer

Is the scope of primitive functions in The Little Schemer incorrect?

Consider the following s-expression: ((lambda (car) (car (quote (a b c)))) cdr) In most scheme implementations I've tried, this evaluates to (b c) because cdr is passed to the lambda, which names it car, taking precedence over the primitive…
Jeremy Huiskamp
  • 5,186
  • 5
  • 26
  • 19
3
votes
1 answer

scheme continuation inside a for-each

I'm currently studying Scheme for a course at my university, while looking at some exercises I got stuck on this particular one. Professor has yet to answer my previous mails therefore I have more chances to receive an answer here faster. Given this…
MaX
  • 489
  • 7
  • 18
3
votes
2 answers

How to load the slib library in chez scheme?

How to load the slib library in chez scheme? Or any other web server library for chez scheme? On the manual of slim it says: Configure the Scheme implementation(s) to locate the SLIB directory and implementation directories. Arrange for each…
guenchi
  • 61
  • 6