CMPU 101 Lecture Notes - Lecture 5: Eval

16 views3 pages

Document Summary

Quote: (quote x) suppresses evaluation (abbreviated as x) If: (if boolean-exp then-exp else-exp) (if true evaluates the then-exp and ignores else-exp. 1 of then-exp or else-exp is not eval) When: (when boolean-exp then-exp) (it"s like the if special form but only with the true part) Ex: (cond ((boolean-exp(1)) (return- result(1)))) (as many boolean-exp can be added) Looks like: (lambda (c1, c2, . , cn (parameter list, symbols that are unique)) b) Ex (if special form): write a function letter-grade to consume a number between 0100 to give grades a b c to the 90%, 80%, 70% cutoff (define letter-grade (lambda (score) (if (>= score 90) Ex (cond special form): (same example above) (define high 90) (define middle 80) (define low 70) (define letter-grade-v2 (lambda (score) (cond ((>= score high) a) ((>= score mid) b) ((>= score low) c) (else d)))) Continues looking for a false, once it does then everything returns back as false.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents