4 ms·
Forgive my terrible macroing but, if your really must, you can: (defmacro ord-compare [a ord b] `(if (or (= > ~ord) (= < ~ord)) (~ord ~a ~b) "Use > o
by minikomi 13y ago
Forgive my terrible macroing but, if your really must, you can:
(defmacro ord-compare [a ord b]
`(if (or (= > ~ord) (= < ~ord)) (~ord ~a ~b) "Use > or < to compare."))
(ord-compare 3 > 2)
Edit: there's also incanter.inflix, which will translate inflix notation into clojure like notation.
https://github.com/liebke/incanter/blob/e1235cf9ffa2e528823eefa4187ed7210b156bd5/modules/incanter-core/src/incanter/infix.clj https://github.com/liebke/incanter/blob/e1235cf9ffa2e528823e...
Check out the tests for how to use it:
https://github.com/liebke/incanter/blob/aa71f1135c3beb7bf7a4dc060c479b8680dd6c95/modules/incanter-core/test/incanter/infix_tests.clj https://github.com/liebke/incanter/blob/aa71f1135c3beb7bf7a4...
A good example:
; $= translates inflix to prefix notation.
($= 3 <= (5 * 2/7)) ;will give you false.