From 13572486b3b43e3f6210e0c8d8b37bb4dcab5d89 Mon Sep 17 00:00:00 2001 From: daniel watson Date: Tue, 16 Aug 2016 21:05:59 -0700 Subject: [PATCH] start notes on conditions --- notes.org | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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" -- 2.30.2