Hi Parth,

It is on the agenda to support this for pprint, but I don't know
exactly when.

In the meantime, arbitrary bases *are* supported in the common lisp
compatible format function (cl-format) which is also part of
clojure.contrib.pprint.

The interesting directives are ~X, ~B, and ~bR, where b is the base of
interest. For example,

(cl-format nil "~X" 256) => "100"

(cl-format nil "~12r" 256) => "194"

(cl-format true "~{~X ~}~%" [2 4 8 16 32 64 128 256])

prints to *out*:

2 4 8 10 20 40 80 100

For all the dirt on using radix, look at the Common Lisp Hyperspec:
http://www.lispworks.com/documentation/HyperSpec/Body/22_cb.htm

More info about the clojure implementation of format here:
http://code.google.com/p/clojure-contrib/wiki/CommonLispFormat (a
little out of date and about to be moved).

HTH,

Tom
On Jul 2, 1:51 am, Parth Malwankar <parth.malwan...@gmail.com> wrote:
> I frequently deal with hex and binary numbers.
> As of now when I need to view a list of numbers
> I just map a little hex function to it to translate it
> into a list of hex strings at the repl.
>
> Having something like *print-base* / *print-radix* [1] may be
> valuable in such a scenario
>
> Or maybe an enhanced pprint? Not sure if pprint already provides
> such an option or if its planned.
>
> I would appreciate any comments or ideas if someone
> is doing something similar.
>
> Thanks.
> Parth
> [1]http://www.lispworks.com/documentation/lw50/CLHS/Body/v_pr_bas.htm
--~--~---------~--~----~------------~-------~--~----~
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