<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Op 22-2-2012 9:58, Roelof Wobben schreef:
<blockquote cite="mid:4F44AE43.5090601@home.nl" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Thanks, <br>
<br>
I have now a answer to my question.<br>
I will debug my programm with check-expect and wil take a look at
the second edition.<br>
<br>
Roelof<br>
<br>
<br>
<br>
Op 21-2-2012 22:40, Stephen Bloch schreef:
<blockquote
cite="mid:4158A01A-A410-4E9D-8B87-31B265D4CBFF@adelphi.edu"
type="cite"><br>
<div>
<div>On Feb 21, 2012, at 3:18 PM, Roelof Wobben wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div bgcolor="#FFFFFF" text="#000000"> Op 21-2-2012 20:51,
Stephen Bloch schreef:
<blockquote
cite="mid:C462650F-784E-463B-B671-61FF7B1BCDC9@adelphi.edu"
type="cite">
<pre wrap="">On Feb 21, 2012, at 2:43 PM, Roelof Wobben wrote:
</pre>
<blockquote type="cite">
<pre wrap="">But now I get this error message :
unsaved editor>:27:23: function call: expected a function after the open parenthesis, but found a part in: (tarief1 amount)
When I do (tarief 1 amount) instead of ((tarief amount))
</pre>
</blockquote>
<pre wrap="">Yes, that's where the syntax error is. So you've fixed that.</pre>
</blockquote>
<br>
I fixed that? I always thought that if I use another
function that I must be into ().<br>
So In my opinion one () for the then part and one () for
the function call. <br>
</div>
</blockquote>
<div><br>
</div>
No, there is no pair of parentheses for the "then" part, only
one for the function call.</div>
<div><br>
</div>
<div>(cond [question answer]</div>
<div> [question answer]</div>
<div> ...</div>
<div> [question answer])</div>
<div>where each question and each answer is an expression
(usually a function call).</div>
<div><br>
<blockquote type="cite">
<div bgcolor="#FFFFFF" text="#000000">
<blockquote
cite="mid:C462650F-784E-463B-B671-61FF7B1BCDC9@adelphi.edu"
type="cite">
<pre wrap="">1) Have you written a complete set of test cases, with right answers, using "check-expect"? Since there are four categories of input for this problem, you need at least four test cases, and you should probably have three more for the boundaries, a total of seven test cases.
</pre>
</blockquote>
<br>
Nope, check-expect is not explained on chapter section 3
of the book how to design programms. So I did not use that
function. I can make test-cases but then in this form <br>
<br>
(<span class="builtin">=</span> (<i>tarief 495</i><span
class="selfeval"></span>) 1,2375) <br>
</div>
</blockquote>
<div><br>
</div>
That should work too, although it's not as convenient. Make
sure you put a bunch of those test cases in the Definitions
pane, after the definition:</div>
<div><br>
</div>
<div>(define (tarief blah blah)</div>
<div> blah blah blah</div>
<div> )</div>
<div><br>
</div>
<div>(= (tarief 495) 1,2375)</div>
<div>(= (tarief 0) 0)</div>
<div>(= (tarief 100) whatever)</div>
<div>...</div>
<div><br>
</div>
<div>That will also solve the next problem:</div>
<div><br>
</div>
<div>
<blockquote type="cite">
<div bgcolor="#FFFFFF" text="#000000">3) Have you used the
Stepper to watch what your program is doing? <br>
<br>
Yes, when I do (payback 2600) on the prompt and press Step
I only see a message All definitions have been
sucessfully evaluated and not other outcome so that did
not help me any further. <br>
</div>
</blockquote>
</div>
<br>
<div>The Stepper only works on expressions in the Definitions
pane, not the Interactions pane. If you put your test cases
in the Definitions pane as described above, the Stepper will
help you find where things are going wrong.</div>
<div><br>
</div>
<div>BTW, check-expect is not discussed in _How to Design
Programs_ because it hadn't been invented yet when the book
was written. It's quite easy to use, though: replace the =
sign in the above tests with check-expect, and when you hit
"Run" you'll get a report of which of your test cases worked,
the expected answer and the actual answer.</div>
<div><br>
</div>
<div>You might consider working through the Second Edition of
_How to Design Programs_ instead; see <a
moz-do-not-send="true"
href="http://www.ccs.neu.edu/home/matthias/HtDP2e/">http://www.ccs.neu.edu/home/matthias/HtDP2e/</a>
.</div>
<div><br>
</div>
<br>
<br>
<div> <span class="Apple-style-span" style="border-collapse:
separate; color: rgb(0, 0, 0); font-family: Helvetica;
font-size: medium; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; line-height:
normal; orphans: 2; text-align: auto; text-indent: 0px;
text-transform: none; white-space: normal; widows: 2;
word-spacing: 0px; -webkit-border-horizontal-spacing: 0px;
-webkit-border-vertical-spacing: 0px;
-webkit-text-decorations-in-effect: none;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width:
0px; "><span class="Apple-style-span"
style="border-collapse: separate; color: rgb(0, 0, 0);
font-family: Helvetica; font-size: medium; font-style:
normal; font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal; orphans: 2;
text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px;
-webkit-border-horizontal-spacing: 0px;
-webkit-border-vertical-spacing: 0px;
-webkit-text-decorations-in-effect: none;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width:
0px; ">
<div style="word-wrap: break-word; -webkit-nbsp-mode:
space; -webkit-line-break: after-white-space; ">
<div>Stephen Bloch</div>
<div><a moz-do-not-send="true"
href="mailto:sbloch@adelphi.edu">sbloch@adelphi.edu</a></div>
</div>
</span></span> </div>
<br>
</blockquote>
<br>
</blockquote>
<br>
I found a working solution but I wonder if there is a better way to
achieve the answer in the Beginning Student modus.<br>
<br>
The solution I found is this one:<br>
<br>
<br>
(define (tarief4 amount)<br>
(*(- amount 2500)0.01))<br>
<br>
<br>
(define (tarief3 amount)<br>
(cond<br>
[ ( < amount 2500)(* (- amount 1500)0.0075)]<br>
[ else ( * .0075 1000)]))<br>
<br>
(define (tarief2 amount)<br>
(cond<br>
[ ( < amount 1500)(* ( - 1000 amount) .0050) ]<br>
[ else ( * 1000 0.0050)]))<br>
<br>
<br>
(define (tarief1 amount)<br>
(cond<br>
[ (< amount 500) (* 0.0025 amount)]<br>
[ else (* 0.0025 500)]<br>
))<br>
<br>
<br>
(define (payback amount)<br>
(cond<br>
[ (<= amount 500) (tarief1 amount)]<br>
[ (and ( <= amount 1500) (> amount 500)) (+ (tarief1
amount)(tarief2 amount))]<br>
[ (and ( <= amount 2500) (> amount 1500)) (+ (tarief3
amount) (tarief2 amount) (tarief1 amount))]<br>
[ else (+ (tarief4 amount)(tarief3 amount)(tarief2
amount)(tarief1 amount))]<br>
)<br>
)<br>
<br>
<br>
Roelof Wobben<br>
<br>
</body>
</html>