CSC153 2004S, Class 17: Higher Order Procedures (2) Admin: * Exam 1 due. How long did it take? * No reading for tomorrow. * HW 4 assigned. * Cool biocomputing talk tomorrow at 4:30. Extra credit for attending and reflecting. Overview: * Some more fun with higher-order procedures: * Operator sections * Combining boolean operations * Procedure definition, reconsidered * Lab More about Higher-Order Procedures * "Real" Schemers tend to use higher-order procedures to define new procedures (define disjunction (lambda (pred1? pred2?) (lambda (x) (or (pred1? x) (pred2? x))))) OLD STYLE (define symbol-or-string? (lambda (x) (or (symbol? x) (string? x))))) NEW STYLE (define symbol-or-string? (disjunction symbol? string?)) (define symbol-or-string? (or symbol? string?)) => symbol? * "Real" Schemers (e.g., Mr. Stone) therefore often write procedures that are useful for defining other procedures (define left-section (lambda (binary-proc arg1) (lambda (arg2) (binary-proc arg1 arg2)))) * "and" is not a procedure. It is instead a syntactic construct. * "and" is not a procedure because it has a different order of operations than normal procedure application (define silly (lambda (x) (display x) (newline) x)) TRY THE LAB! (Updated during class.)