Skip to content

Commit

Permalink
Add inc/dec
Browse files Browse the repository at this point in the history
Close #275
  • Loading branch information
yurrriq committed Sep 13, 2016
1 parent aa11709 commit a51e4b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/clj.lfe
Expand Up @@ -628,6 +628,13 @@
N.B. This is like Haskell's `const` rather than Clojure's `constantly`."
(lambda (_) x))

(defn inc [x]
"Increment `x` by 1."
(+ x 1))

(defn dec [x]
"Decrement `x` by 1."
(- x 1))

;;; Internal functions.

Expand Down
12 changes: 10 additions & 2 deletions test/clj-tests.lfe
Expand Up @@ -611,7 +611,7 @@
(is-error 'function_clause (clj:repeat -1 0))
(is-error 'function_clause (clj:repeat -1 (lambda () 1))))
;;; identity and constantly
;;; Other functions.
(deftest identity
(are* [x] (ok? (is-match x (clj:identity x)))
Expand All @@ -634,4 +634,12 @@
(are* [x] (ok? (is-match 10 (c0 x)))
'nil
42
"foo")))
"foo")))
(deftest inc
(is-match 2 (clj:inc 1))
(is-match 4.0 (clj:inc 3.0)))
(deftest dec
(is-match 2 (clj:dec 3))
(is-match 4.0 (clj:dec 5.0)))

0 comments on commit a51e4b3

Please sign in to comment.