Tom, Chouser, Thanks for your responses. As of now I am doing the same thing as suggested. However, this tends be become painful the moment structures start to nest. For e.g. I am using Clojure to decode a bit of assembly and below is what I end up doing to see the values of interest in hex:
user=> (decode :b32 (nth test-ops 3)) {:inst {:prefix (), :code (199 69 248 10 0 0 0), :op :movl, :args [{:type :Ev-mem, :arg {:reg :ebp, :disp -8}} 10]}, :more ()} user=> (def r (decode :b32 (nth test-ops 3))) #'user/r user=> (map hex (get-in r [:inst :code])) ("c7" "45" "f8" "a" "0" "0" "0") user=> (hex (second (get-in r [:inst :args]))) "a" user=> Basically, I need to extract each number seq or value individually and print it in hex for every instruction I decode and view. This isn't too much fun to do in the middle of a debug session :) Having something like *print-base* would be ideal IMHO would make scenarios like this really easy as one could simply do: user=> (set! *print-base* 16) user=> (decode :b32 (nth test-ops 3)) {:inst {:prefix (), :code (c7 47 f8 a 0 0 0), :op :movl, :args [{:type :Ev-mem, :arg {:reg :ebp, :disp f8}} a]}, :more ()} In the absence of this I thought of writing a function that would take an arbitrary Clojure structure/coll and print it out in the manner like above. But then it won't be much different from pprint with radix support but without the pretty part. I suppose what I am hoping is that a feature request for *print-base* sort of a mechanism get considered for Clojure as it makes scenarios like the above very easy to deal with. Any chance of this being somewhere on the Clojue todo? :) I will probably create a poor mans radix based print in the mean time for the this scenario. That should be an interesting exercise. Thanks, Parth On Jul 2, 10:58 pm, Chouser <chou...@gmail.com> wrote: > On Thu, Jul 2, 2009 at 4: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 > > I don't think Java's built-in formatter is nearly as > flexible as those, but getting hex or octal strings is easy > enough: > > user=> (format "%d" 255) > "255" > user=> (format "%o" 255) > "377" > user=> (format "%x" 255) > "ff" > user=> (format "%X" 255) > "FF" > > --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---