The contract for '~r' deliberately excludes +nan.0, +inf.0, etc---that's why it's 'rational?' and not 'real?'. The point of '~r' is to provide numeric formatting options, none of which apply to +nan.0, etc.

Ryan


On 03/04/2013 01:26 PM, Ray Racine wrote:
Currently  the `~r' format routine, which accepts rationals, barfs on
+nan.0 and siblings, which are not rationals.  My current use case is
simply displaying sub-ranges of vectors of flonums.  It is not a problem
to check for +nan.0 and explicitly display it. I was just wanted to toss
it out as a don't know what is the "right thing" for the `~r' format
routine to do here.

 > (define: x : Flonum +nan.0)
 > (define: y : Flonum 3.145962)
 > (~r y)
- : String
"3.145962"
 > (~r x)
~r: contract violation
  expected: rational?
  given: +nan.0
...



____________________
   Racket Users list:
   http://lists.racket-lang.org/users


____________________
 Racket Users list:
 http://lists.racket-lang.org/users

Reply via email to