Using docs effectively (Ratio)

36 views
Skip to first unread message

Jacek Generowicz

unread,
Jan 21, 2010, 7:57:37 AM1/21/10
to Clojure
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 ?

Thank you.

Rich Hickey

unread,
Jan 29, 2010, 8:37:31 AM1/29/10
to clo...@googlegroups.com

I'd welcome a patch that exposed these methods as functions in core.

Rich

Meikel Brandmeyer

unread,
Jan 29, 2010, 3:07:54 PM1/29/10
to clo...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages