We dissect nature along lines laid down by our native language. ... Language is not simply a reporting device for experience but a defining framework for it.-- Benjamin Whorf, Thinking in Primitive Communities
It is up to us to produce better-quality movies.-- Lloyd Kaufman, producer of Stuff Stephanie in the Incinerator
(define foo
(lambda (n)
(if (< n 10)
n
(let ((m (quotient n 10)))
(+ (- n (* m 10))
(* 100 (foo m)))))))
((mary had (a (little) lamb)) (its fleece) was (white (as snow)))
| expression | result |
|---|---|
((lambda (x f) (f x x)) 'aye (lambda (y z) (list z y y))) | |
(map (repeat car 2)
'(((a b) (c d))
((e f) (g h))
((h i) (j k))))
| |
(map (lambda (x)
(if (number? x) x (x 6)))
(list 13
-
list
(lambda (x) (/ x 2))
even?))
| |
(accumulate (lambda (x y)
(list (car y)))
'((a b) (d e f) (g h)))
| |
(list (or 'w 'x 'y)
(and 'm 'n 'o)
(caadr
(assoc 'x
'(((y z) x)
(x (w y))
(p (d q))))))
| |
(let ((x 'ex)
(y 'why))
(let ((y (list x y))
(z (list y y x)))
(list x y z)))
|
| definition | tail recursive | not t.r. |
|---|---|---|
(define bar
(lambda (x y)
(and (not (null? y))
(if (equal? x (car y))
y
(bar x (cdr y))))))
| ||
(define tr
(lambda (s q)
(cond ((pair? s)
(cons (tr (cdr s) q)
(tr (car s) q)))
((null? s) q)
(else (list s)))))
|
Example:
(map-skip car '((a b) (c d) (e f) (g h) (i j) (p q) (r s) (t u))) ;;; returns: (a (c d) e (g h) i (p q) r (t u))
| expression | result |
|---|---|
`(a ,(+ 1 2) (+ 3 4) ,5) | |
(let ((x '(a b c))) `(1 (+ 2 3) ,@x 4 (5 ,x 6))) | |
(map (lambda (x)
`(,(+ 1 (car x))
,@(cdr x)
foo))
'((10 100 1000)
(20 200 2000)
(50 5 555)))
| |
(accumulate (lambda (x y) `(,@x - ,@y -)) '((a b c) (d e) (f g h))) |
For instance
(acrost '((a b c) (1 2 3) (d e f g) (w x y z) (11 12 13 14 15 16))) ;;; returns: (a 2 f z 15)
(define foo
(lambda (s)
(define aux
(lambda (s ops)
(cond ((pair? s)
(append (aux (car s) (cons 0 ops))
(aux (cdr s) (cons 1 ops))))
(else `((,(reverse ops) ,s))))))
(aux s '())))
(foo '((a b) c d))