As I said tweaking `format` to work on rationals could be too much,
and i can restate that as "it is too much".

Nevertheless, extending it to work on bigint doesn't seem to me really
an edge case, given that i could get a bigint out of any function that
uses autopromotion, so:

(printf "%d" (autopromoting-factorial N))

would work only for small enough inputs. That's a bit surprising, so i
keep my +1 while I learn cl-format.

Then, if cl-format, is the "true" formatting function for clojure, why
isn't it in core?

On Jul 28, 2:48 pm, Chas Emerick <cemer...@snowtide.com> wrote:
> Tweaking `format` so that it accounts for all sorts of edge cases almost 
> certainly isn't going to happen, and would be a horrible kludge in any case.
>
> To extend Tom's point, if you really want a format that knows about all of 
> Clojure's scalars and data structures, cl-format is what you want, and it 
> comes with the language.  If you don't want to learn about cl-format, then a 
> local wrapper around `format` that does whatever you like re: coercions to 
> standard Java numeric types would be ~3 lines.
>
> - Chas
>
> On Jul 28, 2011, at 7:52 AM, Andrea Tortorella wrote:
>
>
>
>
>
>
>
> > Thanks for your replies,
>
> > +1 for enhancing format
>
> > Maybe it could handle also rationals, converting them to doubles, but
> > it could be to much.
>
> > On Jul 28, 9:47 am, Sean Corfield <seancorfi...@gmail.com> wrote:
> >> On Wed, Jul 27, 2011 at 11:48 PM, Tom Faulhaber <tomfaulha...@gmail.com> 
> >> wrote:
> >>> FWIW, clojure.pprint.cl-format handles this fine in 1.3:
>
> >>> (cl-format nil "~d" 2N)
> >>> => "2"
>
> >> Wow, I just spent the last 30 minutes reading Common Lisp the
> >> Language, 2nd Ed, chapter 22 which describes how powerful and
> >> mind-bending that is...

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to