Scheme is a functional programming language in the Lisp family, closely modeled on lambda calculus with eager (applicative-order) evaluation.

learn more… | top users | synonyms

23
votes
1answer
1k views

Merge sort in Scheme

...
6
votes
1answer
741 views

Code from “Write Yourself a Scheme in 48 Hours” tutorial

I recently went through this Haskell tutorial. I'd be interested in any thoughts or comments at all, in terms of improving the structure, order, haskell conventions, or that long, kind of ugly eval ...
6
votes
3answers
127 views

Insertion sort in Scheme

Inspired by my merge sort in Scheme, I thought I'd try my hand at implementing other sorting algorithms, starting with simple ones (like insertion sort) and working my way up. So, here we go: ...
4
votes
1answer
174 views

Is this a good way to implement let-with?

I've implemented a let-with macro that takes an association list, keyed by symbols, that enables code to bind their corresponding values to local variables. It's ...
3
votes
1answer
802 views

Huffman encoding successive-merge function

From SICP: Exercise 2.69. The following procedure takes as its argument a list of symbol-frequency pairs (where no symbol appears in more than one pair) and generates a Huffman encoding ...
3
votes
1answer
695 views

A list builder or list accumulator

Imagine a UTF-8 decoder that takes a list of bytes and returns human-readable code points like: ...
3
votes
1answer
60 views

Replacing elements from a list and its sublists

Write a procedure substitute that takes three arguments: a list, an old word, and a new word. It should return a copy of the list, but with every occurrence of the old word replaced by the new word, ...
3
votes
2answers
1k views

Use Newton's Method to compute sqrt(x)

Given the following task: Use Newton's method to compute the square root of a number. Newton's method involves successive approximation. You start with a guess, and then continue averaging ...
3
votes
1answer
97 views

SICP exercise 1.28 - miller-rabin primality test part II

This is a follow-up to SICP exercise 1.28 - miller-rabin primality test. Exercise 1.28: One variant of the Fermat test that cannot be fooled is called the Miller-Rabin test (Miller 1976; ...
2
votes
1answer
115 views

SICP exercise 1.28 - miller-rabin primality test

From SICP Exercise 1.28: One variant of the Fermat test that cannot be fooled is called the Miller-Rabin test (Miller 1976; Rabin 1980). This starts from an alternate form of Fermat’s ...
2
votes
1answer
104 views

lexical scope v let in scheme functions

I've been chewing through a bit of The Little Schemer and the Peano examples got me thinking about operation size and time. I got some help on making Peano Multiplication linear -- however ...
1
vote
1answer
286 views

Defining a unique-pairs procedure

From the section called Nested Mappings Exercise 2.40 Define a procedure unique-pairs that, given an integer n, generates the sequence of pairs (...
1
vote
1answer
78 views

Linear Peano multiplication in Scheme?

I've been running through The Little Schemer, and have hit the example of Peano multiplication. The solution is given in TLS (reproduced below) -- however what interests me is the order of the ...
1
vote
1answer
1k views

remove first occurance of element from list

As explained here i'm learning a limited subset of scheme. My task has been to sort a numerical list. To implement a simple insertion sort, i need to remove a single element from a list. I've ...