<br><br><div class="gmail_quote">On Wed, Dec 22, 2010 at 1:19 PM, Sayth Renshaw <span dir="ltr"><<a href="mailto:flebber.crue@gmail.com">flebber.crue@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Wed, Dec 22, 2010 at 1:02 PM, Danny Yoo <span dir="ltr"><<a href="mailto:dyoo@cs.wpi.edu" target="_blank">dyoo@cs.wpi.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>>> (define (netpay gross tax-rate)<br>
>> (-(gross)(* gross tax-rate)))<br>
>><br>
>> So I expect the function to calculate as<br>
>><br>
>> = (-(240)(* 240 0.15)<br>
>> = ( - 240 36)<br>
>> = 204<br>
<br>
<br>
</div>Just to be more careful: when you're showing the calculation, make<br>
sure to include the use of the function:<br>
<br>
(netpay 240 0.15)<br>
<div> = (-(240)(* 240 0.15)<br>
= ( - 240 36)<br>
= 204<br>
<br>
<br>
</div>There's a hitch on the first step in the calculation, and it has to do<br>
with the parens. Unlike its use in traditional math notation, parens<br>
are significant in this language: that is, every use of paren has to<br>
mean something: it's not superfluous: if you have too many or too few,<br>
it changes the meaning of the program.<br>
<br>
<br>
So, within the larger term here:<br>
<br>
(- (240) (* 240 0.15))<br>
<br>
the subterm<br>
<br>
(240)<br>
<br>
means "call the function 240". That may not be what you intend, but<br>
that what it means in this language.<br>
<br>
<br>
You can see this if you go back to what the error message is saying:<br>
<div><br>
function call: expected a defined function name or a primitive<br>
operation name after an open parenthesis, but found a function<br>
argument name<br>
<br>
</div>It's basically trying to point out this problem, that the use of<br>
"(gross)" within the expression<br>
<br>
(-(gross)(* gross tax-rate))<br>
<br>
is trying to use gross as if it were a function, rather than the<br>
numeric argument to netpay.<br>
</blockquote></div><br>the subterm<br>
<br>
(240)<br>
<br>
means "call the function 240". That may not be what you intend, but<br>
that what it means in this language.<br><br></div></div>Awesome pickup, thank you. Can I ask how I could then specify gross a single item in the formula and not as a function?<br>
</blockquote></div><br>Thank you everyone, I have solved it and thank you for picking me up on the small intricises.<br><br>This is my solution though it works I do feel I "Cheated" somewhat but this is what I have done and tested working.<br>
<br>(define tax-rate 0.15)<br>(define pay-rate 12)<br>(define (gross hours)<br> (* hours pay-rate))<br><br>(define (netpay gross tax-rate)<br> (- gross 0 (* gross tax-rate)))<br><br><br>> (netpay (gross 20)tax-rate)<br>
204<br>> <br><br>Sayth<br>