[racket] Formating Printing of Real Number

From: Danny Yoo (dyoo at hashcollision.org)
Date: Fri Jul 27 14:42:50 EDT 2012

On Fri, Jul 27, 2012 at 2:27 PM, Ray Racine <ray.racine at gmail.com> wrote:
> Unable to locate a means to control the output formatting of
> Real/Floats/what-have-you either via current formatting facilities (format
> procedure etc) or via some parameter.  Is there anything available?

I think you may be looking for the current-print parameter:

    http://docs.racket-lang.org/reference/eval.html#(def._((quote._~23~25kernel)._current-print))


For example:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket
(current-print (lambda (foo)
                 (unless (void? foo)
                   (print "Foo!") (newline))))
(+ 1 2)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

You might look at assigning a useful pretty-printer to current-print,
such as the one in racket/pretty:

http://docs.racket-lang.org/reference/pretty-print.html#(def._((lib._racket/pretty..rkt)._pretty-print))

Posted on the users mailing list.