SchemeTutorial.pdf

(854 KB) Pobierz
Scheme Tutorial (for Artificial Intelligence)
for B551 (and B351)
Please download
Petite Chez Scheme
(Scheme.com)
If you haven’t already
Todd Holloway
Indiana University
08-31-2007
356561163.012.png 356561163.013.png 356561163.014.png
356561163.015.png
Lots of parenthesis (((((((((())))))))))
When debugging, check for mismatched parenthesis
Lots of lists
Schemers love list processing
Lots of recursion
Loops are often recursively defined
And lots of lambdas
Pass variables, functions in many (often imaginative)
ways
356561163.001.png 356561163.002.png
Petite Chez Scheme Version 7.3
;; semi-colons are used for comments
(+ 3 5) ; form is function followed by args
8
(+ (* 2 2) (* 5 5)) ; composition of functions
29
(length '(1 3 5 9 11)) ; first look at lists
5
356561163.003.png 356561163.004.png 356561163.005.png 356561163.006.png 356561163.007.png 356561163.008.png
(eqv? 42 42) ; take a look at eq?, =, and equal? as well
#t
(min 1 3 4 2 3) ; no limit on number of arguments
1
(display 8)
8
(let ((x 3) (y 4) (z 5)) (display (+ x 1))) ; local vars
4
Note: This can be implemented using lambdas instead
356561163.009.png 356561163.010.png 356561163.011.png
Zgłoś jeśli naruszono regulamin