CS151, Class 9: User-Defined Procedures Overview: * Discussion of homework 1 * Why write procedures * Writing your own procedures * Lab * Reflection: Interesting stuff you learned? Notes: * Homework 1 graded. We'll spend some time looking at your work. + Education majors: Is evaluation or grading more important? * Responses to surveys (finally) available online Moral: Sam is a not-so-nice grader ----- Useful to be able to encapsulate a common set of instructions In most languages, we do this action with the procedure * Key idea: A set of instuctions may be *parameterized* Meaning: You can write general instructions that take different inputs In Scheme (define _____ NAME OF PROCEDURE (lambda (___ ___ ___ ___) PARAMS SEPARATED BY SPACES ____)) EXP1 E.g., (define square (lambda (val) (* val val))) Using it > (square 4) 16 Basic model: Evaluate all the parameters and then plug them in in the expression. Evaluate the expression.