<div dir="ltr">(=~ is interesting.  Thanks.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 22 October 2013 13:53, 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"><div class="im"><br>
;; equation3 : number  ->  boolean<br>
;; to determine whether n is a solution for 2n^2  =  102<br>
(define (equation3 n)<br>
</div>  (=~ (* 2 n n) 102 .001))<br>
<br>
<br>
-- Matthias<br>
<div><div class="h5"><br>
<br>
<br>
On Oct 22, 2013, at 8:40 AM, Bo Gus <<a href="mailto:forumangus@gmail.com">forumangus@gmail.com</a>> wrote:<br>
<br>
> equation 2 is 2n^2 = 102 so I implement like this:<br>
><br>
> ;; equation3 : number  ->  boolean<br>
> ;; to determine whether n is a solution for 2n^2  =  102<br>
> (define (equation3 n)<br>
>   (= (* 2 n n) 102))<br>
><br>
> And my answer is the same as per the online answer.  so great.<br>
><br>
> But how can I check a valid answer.<br>
><br>
> Eg if I do:<br>
><br>
> (equation3 (sqrt 51))<br>
> >false<br>
><br>
> same using - square root 51.<br>
><br>
> How can I fix this?  Is the only way to do a range check?  Eg have some sort of tolerance - eg between 0.01 above and below answer?  Any other ideas?<br>
><br>
</div></div>> ____________________<br>
>  Racket Users list:<br>
>  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</blockquote></div><br></div>