<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">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 class="im">>> (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 class="im"> = (-(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 class="im"><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>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>