CS135 Lecture 4: Lecture 4.docx
Document Summary
Differences strings vs. symbols: strings are really compound data (sequence of chars, symbols can"t have certain characters in them, more efficient to compare two symbols than two strings, abbreviations: sym and str. Conditional expressions: conditional expressions use form: cond, each argument is a question/answer pair, question is a boolean expression, answer is a possible value of the conditional expression. In racket, we can compute |x| with (cond. [(>= x 0) x]: square brackets used by convention, for readability. Where questionk could be: else: questions evaluated top-to-bottom, can short-circuit, first true breaks the cond, only one answer is evaluated (the one where question is true) Sometime a question can be simplified by knowing that all previous questions have evaluated to false. Suppose our analysis identifies 3 intervals: students who fail cs must take cs 115, students who pass with below 60 must take cs 116, students with 60 or more take cs 136.