Clojure

add denominator and numerator fns for Ratio

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Backlog
  • Component/s: None
  • Labels:
    None

Description

currently the only way to get the denominator or numerator is via the exposed fields of the Ratio class.

On Thu, Jan 21, 2010 at 7:57 AM, Jacek Generowicz
<jacek.generowicz@googlemail.com> wrote:
> Clojure has a Ratio type; presumably there should be an easy way to
> find the numerator and denominator of a Ratio object.
>
> I didn't have much luck on clojure.org or with find-doc, but
>
> (show 1/2)
>
> taught me that there are numerator and denominator methods on Ratio's
> underlying Java implementation, so I can now do:
>
> (.numerator 1/2) ; => 1
> (.denominator 1/2) ; => 2
>
> Is there a more direct way? (Not that this is bad! But you can't
> use .numerator as a first-order function (though #(.numerator %) is
> still pretty damn good).)
>
> In general, do you have any hints on how to go about looking for
> useful Clojure functions which work with certain Clojure types ?
>

Activity

Hide
Assembla Importer added a comment -

hiredman said: [file:cyO2hUdrir3749eJe5aVNr]: add denominator and numerator fns

Show
Assembla Importer added a comment - hiredman said: [file:cyO2hUdrir3749eJe5aVNr]: add denominator and numerator fns
Hide
Assembla Importer added a comment -

hiredman said: Duplicated association with ticket #254 was added

Show
Assembla Importer added a comment - hiredman said: Duplicated association with ticket #254 was added
Hide
Assembla Importer added a comment -

hiredman said: (In [[r:5772be9fc5ac9ddf92b727908c20b9aab971224a]]) numerator and denominator fns for Ratios, refs #255

Signed-off-by: Rich Hickey <richhickey@gmail.com>

Branch: master

Show
Assembla Importer added a comment - hiredman said: (In [[r:5772be9fc5ac9ddf92b727908c20b9aab971224a]]) numerator and denominator fns for Ratios, refs #255 Signed-off-by: Rich Hickey <richhickey@gmail.com> Branch: master

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: