<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hello, <br>
<br>
This soluation is not what I was looking for.<br>
And it uses list which I don't have learned so far.<br>
<br>
So far I have this : <br>
<br>
; constanten <br>
<br>
(define R 5)<br>
(define first_tekst "Het ingegeven punt")<br>
(define is_tekst "is")<br>
(define middle_tekst "dichtbij het 0 nulpunt")<br>
(define niet "niet")<br>
<br>
<br>
;Number Number -> Number <br>
;This function calculates the distance of a given point compared
to the origin<br>
(check-expect (calculate 1 0) 1)<br>
(check-expect (calculate 3 4) 5)<br>
(check-expect (calculate 0 3) 3)<br>
(define (calculate getal1 getal2)<br>
(cond <br>
[ (equal? getal1 0) getal2]<br>
[ (equal? getal2 0) getal1]<br>
[else (sqrt (+ (* getal1 getal1) (* getal2 getal2)))]<br>
))<br>
<br>
; Struct -> String<br>
; Function who outputs a string dependinh on the outcome of the
calculation of the distance to the origin<br>
(check-expect (is-near (make-s 1 0) "Het ingegeven punt is
dichtbij het nulpunt"))<br>
(check-expect (is-near (make-s 3 4) "Het ingeven punt is niet
dichtbij het nulpunt"))<br>
(define (is-near s r)<br>
( if (< (calculate (posn-x s) (posn-y s)) r) <br>
<br>
<br>
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.<br>
And Im looking for a better solution.<br>
<br>
<br>
<br>
<br>
Op 23-6-2012 23:17, Matthias Felleisen schreef:<br>
</div>
<blockquote
cite="mid:07FAB3AD-7051-4409-8154-7E1E0B4A107B@ccs.neu.edu"
type="cite">
<div><br>
</div>
<div>Assuming you don't literally mean 'print', here is a function
that does what you want: </div>
<div><br>
</div>
<div>
<div>;; Sentence is one of: </div>
<div>;; -- empty </div>
<div>;; -- (cons String Sentence)</div>
<div><br>
</div>
<div>(define s1 '("This" "is" "a" "sentence."))</div>
<div>(define s2 '("And" "this" "is" "one," "too."))</div>
<div><br>
</div>
<div>;; Sentence N -> Sentence </div>
<div>;; add 's' to the 2nd word in s if it is longer than i
letters </div>
<div><br>
</div>
<div>(check-expect (change s1 2) s1)</div>
<div>(check-expect (change s2 3) (cons "And" (cons "thiss" (rest
(rest s2)))))</div>
<div><br>
</div>
<div>(define (change s i)</div>
<div> (if (> (string-length (second s)) i)</div>
<div> (cons (first s) (cons (string-append (second s) "s")
(rest (rest s))))</div>
<div> s))</div>
<div> </div>
</div>
<div><br>
</div>
<div>If it doesn't what you want, follow the design recipe and let
us know at which step you're stuck. </div>
<div><br>
</div>
<div><br>
</div>
<br>
<div>
<div>On Jun 23, 2012, at 2:45 PM, Roelof Wobben wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<div bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">I have another "problem" I try
to solve in my head.<br>
<br>
Suppose I want to change one word in a sentence depening
if a comparision is true or false.<br>
<br>
I could do this in pseudo code.<br>
<br>
if comparision is true then print "it's true" else print
"it's not true"<br>
<br>
It works but I type two time's "it's true".<br>
<br>
Can this be done so I have to type only one time the
sentence and depeding on true or false the word not is
used. <br>
<br>
Roelof<br>
<br>
<br>
<br>
Op 23-6-2012 16:18, Matthias Felleisen schreef:<br>
</div>
<blockquote
cite="mid:47F7EB3C-3C87-4706-B031-F51925000CCC@ccs.neu.edu"
type="cite">
<div><br>
</div>
<div>Origin means (0,0) or plain 0 in English. </div>
<div><br>
</div>
<br>
<div>
<div>On Jun 22, 2012, at 2:42 PM, Roelof Wobben wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
<div bgcolor="#FFFFFF" text="#000000"> Hello, <br>
<br>
I try to make this exercise : <br>
<br>
<div class="SIntrapara"><a moz-do-not-send="true"
name="(counter._mix._(exercise._mix4))"></a><span
style="font-weight: bold;">Exercise</span> 76: A
programmer has chosen to represent locations as
Cartesian points or just points:</div>
<div class="SIntrapara">
<blockquote class="SCodeFlow">
<table class="RktBlk" cellspacing="0">
<tbody>
<tr>
<td><span class="RktCmt">;</span><span
class="RktCmt"> </span><span
class="RktCmt">Location is one of:</span></td>
</tr>
<tr>
<td><span class="RktCmt">;</span><span
class="RktCmt"> </span><span
class="RktCmt">–</span><span
class="RktCmt"> Posn</span></td>
</tr>
<tr>
<td><span class="RktCmt">;</span><span
class="RktCmt"> </span><span
class="RktCmt">–</span><span
class="RktCmt"> Number</span></td>
</tr>
<tr>
<td><span class="RktCmt">;</span><span
class="RktCmt"> </span><span
class="RktCmt">interp. Posn are
positions on the Cartesian grid,</span></td>
</tr>
<tr>
<td><span class="RktCmt">;</span><span
class="RktCmt"> </span><span
class="RktCmt">Numbers are positions
on the number line </span></td>
</tr>
</tbody>
</table>
</blockquote>
</div>
<div class="SIntrapara">Design the function <span
class="RktSym">in-reach</span>, which determines
whether or not a given location’s distance to the
origin is strictly less than some constant<span
class="RktSym">R</span>.<br>
<br>
So I must design a function called in-reach.<br>
<br>
Am I right I need to use two structs (Posn) . One
for the given location and one for the origon ?<br>
<br>
Regards, <br>
<br>
Roelof<br>
<br>
<br>
</div>
<br>
</div>
____________________<br>
Racket Users list:<br>
<a moz-do-not-send="true"
href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br>
</blockquote>
</div>
<br>
</blockquote>
<br>
<br>
</div>
</blockquote>
</div>
<br>
</blockquote>
<br>
<br>
</body>
</html>