Update docs

master
Fredrik Bergroth 11 years ago
parent 549bfd3a15
commit 8707aafd96
  1. 17
      README.md

@ -1663,17 +1663,21 @@ Convenient versions of `let` and `let*` constructs combined with flow control.
If `val` evaluates to non-nil, bind it to `var` and execute body.
`var-val` should be a (`var` `val`) pair.
Note: binding is done according to `-let`.
```cl
(-when-let (match-index (string-match "d" "abcd")) (+ match-index 2)) ;; => 5
(--when-let (member :b '(:a :b :c)) (cons :d it)) ;; => '(:d :b :c)
(--when-let (even? 3) (cat it :a)) ;; => nil
(-when-let ((&plist :foo foo) (list :foo "foo")) foo) ;; => "foo"
(-when-let ((&plist :foo foo) (list :bar "bar")) foo) ;; => nil
```
#### -when-let* `(vars-vals &rest body)`
If all `vals` evaluate to true, bind them to their corresponding
`vars` and execute body. `vars-vals` should be a list of (`var` `val`)
pairs (corresponding to bindings of `let*`).
pairs.
Note: binding is done according to `-let`.
```cl
(-when-let* ((x 5) (y 3) (z (+ y 4))) (+ x y z)) ;; => 15
@ -1685,6 +1689,8 @@ pairs (corresponding to bindings of `let*`).
If `val` evaluates to non-nil, bind it to `var` and do `then`,
otherwise do `else`. `var-val` should be a (`var` `val`) pair.
Note: binding is done according to `-let`.
```cl
(-if-let (match-index (string-match "d" "abc")) (+ match-index 3) 7) ;; => 7
(--if-let (even? 4) it nil) ;; => t
@ -1694,11 +1700,14 @@ otherwise do `else`. `var-val` should be a (`var` `val`) pair.
If all `vals` evaluate to true, bind them to their corresponding
`vars` and do `then`, otherwise do `else`. `vars-vals` should be a list
of (`var` `val`) pairs (corresponding to the bindings of `let*`).
of (`var` `val`) pairs.
Note: binding is done according to `-let`.
```cl
(-if-let* ((x 5) (y 3) (z 7)) (+ x y z) "foo") ;; => 15
(-if-let* ((x 5) (y nil) (z 7)) (+ x y z) "foo") ;; => "foo"
(-if-let* (((_ _ x) '(nil nil 7))) x) ;; => 7
```
#### -let `(varlist &rest body)`

Loading…
Cancel
Save