start notes on conditions
authordaniel watson <ozzloy@gmail.com>
Wed, 17 Aug 2016 04:05:59 +0000 (21:05 -0700)
committerdaniel watson <ozzloy@gmail.com>
Wed, 17 Aug 2016 04:05:59 +0000 (21:05 -0700)
notes.org

index 1c781009dec70bdbb4cbc17d95c113fe93db2f6b..62c078860fc87d9ca66f8d110da703aa42e3b9ad 100644 (file)
--- a/notes.org
+++ b/notes.org
      * 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"