Skip to content

Commit a99aaa7

Browse files
committed
More convex.core tidying
1 parent e432dc2 commit a99aaa7

File tree

1 file changed

+6
-10
lines changed
  • convex-core/src/main/cvx/convex/core

1 file changed

+6
-10
lines changed

convex-core/src/main/cvx/convex/core/core.cvx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@
248248
syms)
249249
nil)
250250

251-
252-
253251
;;;;;;;;;; Logic Operations
254252

255253
(defmacro and
@@ -306,9 +304,10 @@
306304
^{:doc {:description "Similar to `if`, but the test expression in bound to a symbol so that it can be accessed in the `expr-true` branch."
307305
:examples [{:code "(if-let [addr (some-function)] (transfer addr 1000) (fail \"Address missing\"))"}]
308306
:signature [{:params [[sym exp] expr-true expr-false]}]}}
309-
[[sym exp] & branches]
310-
`(let [~sym ~exp]
311-
~(cons 'if sym branches)))
307+
([[sym exp] expr-true]
308+
`(cond ~exp (let [~sym *result*] ~expr-true)))
309+
([[sym exp] expr-true expr-false]
310+
`(cond ~exp (let [~sym *result*] ~expr-true) ~expr-false)))
312311

313312
(defmacro when
314313
^{:doc {:description "Executes body expressions in an implicit `do` block if and only if the `test` expression evaluates to a truthy value (anything but false or nil)."
@@ -326,11 +325,8 @@
326325
:examples [{:code "(when-let [addr (some-function)] (transfer addr 1000))"}]
327326
:signature [{:params [[sym exp] & body]}]}}
328327
[[sym exp] & body]
329-
(let [dobody (cons 'let [sym 'test#]
330-
body)]
331-
`(let [test# ~exp]
332-
(cond test#
333-
~dobody))))
328+
`(cond ~exp (let [~sym *result*] ~(cons 'do body
329+
))))
334330

335331
(defmacro when-not
336332
^{:doc {:description "Like `when` but the opposite: body is executed only if the result is false or nil."

0 commit comments

Comments
 (0)