<div dir="ltr">Well long day... I was getting lost in basically getting a Number -> Float.<div><br></div><div style>So for example:</div><div style><br></div><div style><div>(: S->F : String -> (Option Float))</div>
<div>(define (S->F s)</div><div> (define n (string->number s))</div><div> (and (flonum? n) n))</div><div><br></div><div>(S->F "3") ;; Fails</div><div style><br></div><div style><br></div><div style><div>
For some reason I was thinking I had to got through exact? and inexact? type tests and I didn't find the real->double-flonum until just now.</div><div><br></div><div>The below works for me.</div><div><br></div></div>
<div style><div><div>(: S->F : String -> (Option Float))</div><div>(define (S->F s)</div><div> (let ((n (string->number s)))</div><div> (if (real? n)</div><div> (real->double-flonum n)</div><div>
#f)))</div></div><div><br></div><div style><br></div><div style><br></div><div style><br></div><div style><br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 13, 2013 at 10:04 PM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
#lang typed/racket<br>
<br>
(: S->F : String -> (Option Float))<br>
(define (S->F s)<br>
(define n (string->number s))<br>
(and (flonum? n) n))<br>
<br>
I assume you mean to convert strings into floats, if possible.<br>
<br>
But you may like the funny answers better -- Matthias<br>
<div class="im HOEnZb"><br>
<br>
<br>
On Feb 13, 2013, at 9:49 PM, Ray Racine wrote:<br>
<br>
> What is the most efficient way to write the following method in TR?<br>
><br>
> (: S->F (String -> (Option Float)))<br>
><br>
><br>
</div><div class="HOEnZb"><div class="h5">> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</div></div></blockquote></div><br></div>