Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic math operator aliases #3

Open
Necronian opened this issue May 25, 2017 · 1 comment
Open

Basic math operator aliases #3

Necronian opened this issue May 25, 2017 · 1 comment

Comments

@Necronian
Copy link

Necronian commented May 25, 2017

Instead of aliasing / + - * to the equivalent decimal functions can they instead be functions that operate in the same manner as clojure?

I wrote this after looking at clojure.core:

(defn +
([] (decimal 0))
([x] (decimal x))
([x y] (plus x y))
([x y & more] (reduce + (+ x y) more)))

(defn -
([x] (neg x))
([x y] (minus x y))
([x y & more] (reduce - (- x y) more)))

(defn /
([x] (div 1 x))
([x y] (div x y))
([x y & more] (reduce / (/ x y) more)))

(defn *
([] (decimal 1))
([x] (decimal x))
([x y] (mul x y))
([x y & more] (reduce * (* x y) more)))

@niwinz
Copy link
Member

niwinz commented May 28, 2017

PR welcome for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants