Re: Write big numbers with thousands grouping.

2009-11-02 Thread John Harrop
On Mon, Nov 2, 2009 at 12:34 PM, Stuart Sierra wrote: > On Oct 31, 12:37 pm, John Harrop wrote: > > For some reason though changing "defmacro" here to "definline" doesn't > work. > > It says > > > > # this > > context (NO_SOURCE_FILE:129)> > > definline doesn't support variable arities. As in,

Re: Write big numbers with thousands grouping.

2009-11-02 Thread Stuart Sierra
On Oct 31, 12:37 pm, John Harrop wrote: > For some reason though changing "defmacro" here to "definline" doesn't work. > It says > > # context (NO_SOURCE_FILE:129)> definline doesn't support variable arities. -SS --~--~-~--~~~---~--~~ You received this message be

Re: Write big numbers with thousands grouping.

2009-10-31 Thread John Harrop
On Sat, Oct 31, 2009 at 1:23 PM, Stuart Sierra wrote: > > For even more fun, you can take advantage of the fact that commas are > whitespace, and use a macro to do it at compile time: > > (defmacro bignum [& parts] > (read-string (apply str parts))) > > (bignum 99,871,142) > 99871142 Eh. Who ne

Re: Write big numbers with thousands grouping.

2009-10-31 Thread Stuart Sierra
For even more fun, you can take advantage of the fact that commas are whitespace, and use a macro to do it at compile time: (defmacro bignum [& parts] (read-string (apply str parts))) (bignum 99,871,142) 99871142 -SS --~--~-~--~~~---~--~~ You received this messa

Write big numbers with thousands grouping.

2009-10-31 Thread John Harrop
(defn bignum [coll] (reduce #(+ %1 (apply * %2)) 0 (map vector (reverse coll) (iterate #(* 1000 %) 1 user=> (bignum [102 317 926]) 102317926 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To po