funcool / funcool/decimal

Basic math operator aliases

Open
#3 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
13
Forks
5
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.