PSYC 315 Lecture Notes - Lecture 4: Pseudocode

15 views4 pages

Document Summary

Iteration: do, mapcar: special forms: neither a function call nor list data. If (if : test is typically a predicate, simple roulette: pseudocode, function: roulette, parameter: bet. If spin = bet: then return win, else return lose, example of if (defun roulette (bet) If spin = bet then win. (if (= (1+ (random 37)) bet) Lose): complicating the basic if, multiple conditions connected by and, or (and test1 test2 ) (or test1 test2 , multiple consequents or alternatives headed by progn (progn expr1 expr2 , cond is the classical conditional (cond ( 2: when a test returns true, its consequents are evaluated, value of last evaluated consequent is returned, roulette with error check: pseudocode, function: roulette, parameter: bet, check for incorrect bet. If bet is not an integer, >37, or <1, then return illegal-bet: else if spin = bet, then return win, else return lose, roulette with cond (defun roulette-with-error-check (bet)

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