Math abstractions. Currently defines a protocol and type for mixed numbers. Provides a sane replacement for clojure.core.rationalize! that always returns a rational number.
MixedNumber can then more rationally render Clojure's Rational type as strings, but can also be used to decompose decimals or rationals > 1 into mixed numbers with easy access to the whole and fractional parts.
Math abstractions. Currently defines a protocol and type for mixed numbers. Provides a sane replacement for clojure.core.rationalize! that always returns a rational number. MixedNumber can then more rationally render Clojure's Rational type as strings, but can also be used to decompose decimals or rationals > 1 into mixed numbers with easy access to the whole and fractional parts.
A protocol for numbers that can be split into parts.
A protocol for numbers that can be split into parts.
(decompose this)
Returns a map consisting of the parts that make up 'this' number.
Returns a map consisting of the parts that make up 'this' number.
Formally define a MixedNumber's Map representation as returned by the (.decompose num) method.
Formally define a MixedNumber's Map representation as returned by the (.decompose num) method.
(rationalize! n)
Inputs: [n :- s/Num] Returns: Ratio
Like clojure.core.rationalize, but always returns a Ratio, even if the number can be reduced to n/1 See also: http://dev.clojure.org/jira/browse/CLJ-1435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
Inputs: [n :- s/Num] Returns: Ratio Like clojure.core.rationalize, but always returns a Ratio, even if the number can be reduced to n/1 See also: http://dev.clojure.org/jira/browse/CLJ-1435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close