Added rule to match if-not/do -> when-not

This commit is contained in:
Michiel Borkent 2013-03-17 15:27:04 +01:00
parent 3d0c2077ae
commit c6c6a9f971
2 changed files with 4 additions and 1 deletions

View file

@ -11,6 +11,7 @@
[(if-let ?binding ?expr nil) (when-let ?binding ?expr)]
[(when ?x (do . ?y)) (when ?x . ?y)]
[(when-not ?x (do . ?y)) (when-not ?x . ?y)]
[(if-not ?x (do . ?y)) (when-not ?x . ?y)]
;; suggest `while` for bindingless loop-recur
[(loop [] (when ?test . ?exprs (recur)))

View file

@ -15,6 +15,8 @@
'(let [a 1] (println a) a) '(let [a 1] (do (println a) a))
'(when test (println a) then) '(when test (do (println a) then))
'(when-not test (println a) then) '(when-not test (do (println a) then))
'(when-not test body) '(if (not test) (do body))
'(when-not test body) '(if-not test (do body))
'(loop [a 4] (println a) (if (zero? a) a (recur (dec a))))
'(loop [a 4] (do (println a) (if (zero? a) a (recur (dec a)))))))