BillHung.Net


powered by FreeFind     sms

Scheme

23 Jan 2005

W1W Lecture 1

STk> 3
3
STk> (+ 2 3)
5
STk> (+ 2 3 7 100 45)
157
STk> (+ 6)
6
STk> (+)
0
STk> (*)
1
STk> (sqrt 16)
4
STk> (+ (* 2 3) 4)
10
STk> +
(error, something weird)
STk> '+
+
STk> '(+ 2 3)
(+ 2 3)
STk> (last '(+ 2 3))
3
STk> (+ '2 '3)
5
STk> "("
"("
STk> (last 'john)
n
STk> (first 'paul)
p
STk> (last 'john paul)
(error)
STk> (butlast '(magical mystery tour))
(magical mystery)
STk> (butlast '(john))
()
STk> (first (bf '(magical mystery tour)))
mystery
STk> (* (first 20) (bf 123))
46
STk> (define pi 3.14)
pi
STk> pi
3.14
STk> (define (square x)
(* x x)
STk> (square (+ 2 3) )
25
STk> (number? 3)
#t
STk> (number? 'tom)
#f
STk> (define (plural wd)
(word wd 's))
STk> (plural 'computer)
computers
STk> (plural 'fly)
flys
STk> (define (plural wd)
(if (equal? (last wd) 'y)
(word (bl wd) 'ies)
(word wd 's)))
STk> (plural 'fly)
flies
STk> (plural 'boy)
boies