cookbook: fix jerboa-match to forms that actually work in Jerboa
ober
1f91ee44c6b8e8df72efab7edd3cbe2de5a7c2b2
--- a/data/cookbooks.sexp +++ b/data/cookbooks.sexp @@ -39,10 +39,10 @@ ("title" . "Hash Table Creation and Access")) (("code" . - "(import (jerboa prelude))\n\n; Basic match\n(def (describe x)\n (match x\n [0 \"zero\"]\n [(? number? n) (format \"number ~a\" n)]\n [(? string? s) (format \"string: ~a\" s)]\n [(a b) (format \"pair: ~a ~a\" a b)]\n [(a . rest) (format \"list starting with ~a\" a)]\n [_ \"other\"]))\n\n(display (describe 42)) ; => \"number 42\"\n(display (describe \"hi\")) ; => \"string: hi\"\n(display (describe '(1 2 3))) ; => \"list starting with 1\"") ("id" . "jerboa-match") ("imports" "(jerboa prelude)") + "(import (jerboa prelude))\n\n; Basic match\n(def (describe x)\n (match x\n [0 \"zero\"]\n [(and (? number?) n) (format \"number ~a\" n)]\n [(and (? string?) s) (format \"string: ~a\" s)]\n [(list a b) (format \"pair: ~a ~a\" a b)]\n [(cons a rest) (format \"list starting with ~a\" a)]\n [_ \"other\"]))\n\n(display (describe 42)) ; => \"number 42\"\n(display (describe \"hi\")) ; => \"string: hi\"\n(display (describe '(1 2 3))) ; => \"list starting with 1\"") ("id" . "jerboa-match") ("imports" "(jerboa prelude)") ("notes" . - "match is from the jerboa prelude. Patterns include literals, predicates with ?, list patterns, and wildcards _. Also supports (and pat ...), (or pat ...), (not pat) combinators.") + "match is from the jerboa prelude. Patterns include literals, type tests (? pred), list patterns (list a b), head/tail (cons head tail), and wildcard _, plus (and pat ...), (or pat ...), (not pat). To bind a value AND test it, use (and (? pred) var) -- the bare (? pred var) form does NOT bind in Jerboa (it silently no-matches). See recipe match-predicate-bind.") ("tags" "match" "pattern" "case" "cond") ("title" . "Pattern Matching")) (("code"