Tuesday, September 21, 2004
Scheme is Awesome
Scheme is still one of my favourite programming languages. This ask.metafilter thread is turning out to be the best collection of Scheme learning resources I've seen. Stealing some of the links:
- The Little Schemer by Daniel P. Friedman and Matthias Felleisen
- Structure and Interpretation of Computer Programs
- How to Design Programs
- Try the wikipedia scheme entry. Also the useful looking schemers.org
- Two great programs to try are Scheme48 and TinyScheme; both are interpreters for the Scheme language, and both are lightweight. (TinyScheme is exceedingly lightweight.)
- MIT's scheme class is also on open course ware
- Teach Yourself Scheme in Fixnum Days.
(define merge
(lambda (ls-1 ls-2)
(let loop ((rest-1 ls-1)
(rest-2 ls-2)
(merged '()))
(cond ((null? rest-1) (revappend merged rest-2))
((null? rest-2) (revappend merged rest-1))
(else (let ((first-1 (car rest-1))
(first-2 (car rest-2)))
(if (< first-2 first-1)
(loop rest-1 (cdr rest-2) (cons first-2 merged))
(loop (cdr rest-1) rest-2 (cons first-1 merged)))))))))
(define revappend
(lambda (ls-1 ls-2)
(if (null? ls-1)
ls-2
(revappend (cdr ls-1) (cons (car ls-1) ls-2)))))
Basically everything in Scheme is a function, so the if
, loop
, etc. are all actually functions with the conditions and executable code as parameters to the function. This structure makes it simpler to mathematically prove various properties of algorithms implemented in Sheme and other functional languages.
By al -
10:49 p.m. |