CSE 1729 Lecture Notes - Lecture 4: Eval

45 views2 pages
Verified Note

Document Summary

Conditionals via if: simple conditionals are implemented by the if special form (if If it evals to #t: is eval and its val is returned, ex: (if #t 3 4) "three is not bigger than four: the scheme conditional special form: (cond ( ) (guard2> ) ( , you can use else as a guard that always evaluates to be true. 2 (cond (#f 3) (#t 4) (#t 5) (#t 6) 8: function definition: (define (f x) ) [x/5] notation means replace a variable with something else- placed in front of function. Recursion: recursion is the principle tool used to construct rich mathematical objects. The factorial function: recall the factorial function: n! = n x (n-1) x x 1: such a definition can be represented in scheme (define (factorial n) (if (= n 0) If any eval to #f, eval stops (and #f is returned: otherwise #t is returned (or ) also uses "short circuited" eval.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents