From: daniel watson Date: Wed, 17 Aug 2016 04:05:59 +0000 (-0700) Subject: start notes on conditions X-Git-Url: http://challenge-bot.com/repos/?p=ozzloy%40gmail.com%2Frealm-of-racket-journey;a=commitdiff_plain;h=13572486b3b43e3f6210e0c8d8b37bb4dcab5d89 start notes on conditions --- diff --git a/notes.org b/notes.org index 1c78100..62c0788 100644 --- a/notes.org +++ b/notes.org @@ -85,3 +85,24 @@ * lists * structs * nesting of lists and structs +** conditions and decisions +*** how to ask + * predicates are questions + * #t true, and #f false + * predicate is a function that returns true or false + * zero? symbol=? symbol? student? + * doing something like (zero? "asdf") will give an error, not false + * real? number? string? list? cons? empty? rational? exact-integer? + * equal? compares everything. still gives error if you give wrong arity + * the predicate indicates what kind of arguments it works on +*** the conditionals: if and beyond + * (equal? 'yup (if (= (+ 1 2) 3) 'yup 'nope)) + * invented in 1960s by john mccarthy + * #f is false and everything else is true, including '() + * examples + * (if '(1) 'consequent 'alternative) 'consequent + * (if '() 'consequent 'alternative) 'consequent + * (if #f 'consequent 'alternative) 'alternative + * ((if 'a + (display "consequent") + (display "alternative"))) ;; prints "consequent"