Skip to content

Basic math operator aliases #3

Open
@Necronian

Description

@Necronian

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)))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions