[racket] how must I interpreted this exercise

From: Richard Cleis (rcleis at me.com)
Date: Mon Jun 25 00:18:12 EDT 2012

Check-expect is used to test your function. 
Make that work first. 

Then you can use the design recipe to make a new function.

The new function will accept the output of your first function and return the message that you want… without any repeated words in the function.

rac

On Jun 24, 2012, at 1:43 PM, Roelof Wobben wrote:

> Hello, 
> 
> This soluation is not what I was looking for.
> And it uses list which I don't have learned so far.
> 
> So far I have this : 
> 
> ; constanten 
> 
> (define R 5)
> (define first_tekst "Het ingegeven punt")
> (define is_tekst "is")
> (define middle_tekst "dichtbij het 0 nulpunt")
> (define niet "niet")
> 
> 
> ;Number Number -> Number 
> ;This function calculates the distance of a given point compared to the origin
> (check-expect (calculate 1 0) 1)
> (check-expect (calculate 3 4) 5)
> (check-expect (calculate 0 3) 3)
> (define (calculate getal1 getal2)
>   (cond 
>     [ (equal? getal1 0) getal2]
>     [ (equal? getal2 0) getal1]
>     [else (sqrt (+ (* getal1 getal1) (* getal2 getal2)))]
>     ))
> 
> ; Struct -> String
> ; Function who outputs a string dependinh on the outcome of the calculation of the distance to the origin
> (check-expect (is-near (make-s 1 0) "Het ingegeven punt is dichtbij het nulpunt"))
> (check-expect (is-near (make-s 3 4) "Het ingeven punt is niet dichtbij het nulpunt"))
> (define (is-near s r)
>   ( if (< (calculate (posn-x s) (posn-y s)) r)  
>               
> 
> Now I can do  (string append  first_tekst is middle-tekst) and (string-append first-tekst  is niet middle-tekst)  but then I do almost two times the same with one difference the niet part.
> And Im looking for a better solution.
> 


Posted on the users mailing list.