[racket] Value Formatting ~r Routine and Non-Rational +nan.0
While +nan.0 is not a Rational, it is a perfectly valid Number so it sort
of tickled the question as to whether the intent of '~r' is as a Number
formatting procedure or as a Rational formatting procedure. Was just
double (no pun intended) checking intent. I could see it going either way.
Thanks,
Ray
On Mon, Mar 4, 2013 at 2:24 PM, Ryan Culpepper <ryanc at ccs.neu.edu> wrote:
> 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<http://lists.racket-lang.org/users>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130304/219f5e74/attachment.html>