<br><br><div class="gmail_quote">On Wed, Dec 22, 2010 at 2:04 PM, Robby Findler <span dir="ltr">&lt;<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>&gt;</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;">
FWIW, if you were in my class, that solution would get few points. You<br>
may have noticed people asking you about the design recipe in this<br>
thread. That is a reference to this book that you might find useful:<br>
<br>
  <a href="http://www.htdp.org/" target="_blank">http://www.htdp.org/</a><br>
<br>
Robby<br>
<div><div></div><div class="h5"><br>
On Tue, Dec 21, 2010 at 8:49 PM, Sayth Renshaw &lt;<a href="mailto:flebber.crue@gmail.com">flebber.crue@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Wed, Dec 22, 2010 at 1:19 PM, Sayth Renshaw &lt;<a href="mailto:flebber.crue@gmail.com">flebber.crue@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Dec 22, 2010 at 1:02 PM, Danny Yoo &lt;<a href="mailto:dyoo@cs.wpi.edu">dyoo@cs.wpi.edu</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt;&gt;  (define (netpay gross tax-rate)<br>
&gt;&gt;&gt; &gt;&gt;    (-(gross)(* gross tax-rate)))<br>
&gt;&gt;&gt; &gt;&gt;<br>
&gt;&gt;&gt; &gt;&gt; So I expect the function to calculate as<br>
&gt;&gt;&gt; &gt;&gt;<br>
&gt;&gt;&gt; &gt;&gt; = (-(240)(* 240 0.15)<br>
&gt;&gt;&gt; &gt;&gt; = ( - 240 36)<br>
&gt;&gt;&gt; &gt;&gt; = 204<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Just to be more careful: when you&#39;re showing the calculation, make<br>
&gt;&gt;&gt; sure to include the use of the function:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;     (netpay 240 0.15)<br>
&gt;&gt;&gt;     = (-(240)(* 240 0.15)<br>
&gt;&gt;&gt;     = ( - 240 36)<br>
&gt;&gt;&gt;     = 204<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; There&#39;s a hitch on the first step in the calculation, and it has to do<br>
&gt;&gt;&gt; with the parens.  Unlike its use in traditional math notation, parens<br>
&gt;&gt;&gt; are significant in this language: that is, every use of paren has to<br>
&gt;&gt;&gt; mean something: it&#39;s not superfluous: if you have too many or too few,<br>
&gt;&gt;&gt; it changes the meaning of the program.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; So, within the larger term here:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    (- (240) (* 240 0.15))<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; the subterm<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    (240)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; means &quot;call the function 240&quot;.  That may not be what you intend, but<br>
&gt;&gt;&gt; that what it means in this language.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; You can see this if you go back to what the error message is saying:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   function call: expected a defined function name or a primitive<br>
&gt;&gt;&gt; operation name after an open parenthesis, but found a function<br>
&gt;&gt;&gt; argument name<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; It&#39;s basically trying to point out this problem, that the use of<br>
&gt;&gt;&gt; &quot;(gross)&quot; within the expression<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   (-(gross)(* gross tax-rate))<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; is trying to use gross as if it were a function, rather than the<br>
&gt;&gt;&gt; numeric argument to netpay.<br>
&gt;&gt;<br>
&gt;&gt; the subterm<br>
&gt;&gt;<br>
&gt;&gt;    (240)<br>
&gt;&gt;<br>
&gt;&gt; means &quot;call the function 240&quot;.  That may not be what you intend, but<br>
&gt;&gt; that what it means in this language.<br>
&gt;&gt;<br>
&gt;&gt; Awesome pickup, thank you. Can I ask how I could then specify gross a<br>
&gt;&gt; single item in the formula and not as a function?<br>
&gt;<br>
&gt; Thank you everyone, I have solved it and thank you for picking me up on the<br>
&gt; small intricises.<br>
&gt;<br>
&gt; This is my solution though it works I do feel I &quot;Cheated&quot; somewhat but this<br>
&gt; is what I have done and tested working.<br>
&gt;<br>
&gt; (define tax-rate 0.15)<br>
&gt; (define pay-rate 12)<br>
&gt; (define (gross hours)<br>
&gt;   (* hours pay-rate))<br>
&gt;<br>
&gt; (define (netpay gross tax-rate)<br>
&gt;     (- gross 0 (* gross tax-rate)))<br>
&gt;<br>
&gt;<br>
&gt;&gt; (netpay (gross 20)tax-rate)<br>
&gt; 204<br>
&gt;&gt;<br>
&gt;<br>
&gt; Sayth<br>
&gt;<br>
</div></div>&gt; _________________________________________________<br>
&gt;  For list-related administrative tasks:<br>
&gt;  <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
&gt;<br>
</blockquote></div><br>Indeed I know what you are referencing. <br><br><pre class="scheme"><span class="comment">;; <u>Contract</u>: <code class="scheme"><span class="variable">area-of-ring</span> <span class="selfeval">:</span> <span class="variable">number</span> <span class="variable">number</span>  <tt>-&gt;</tt>  <span class="variable">number</span></code></span><br>
<br><span class="comment">;; <u>Purpose</u>: to compute the area of a ring whose radius is</span><br><span class="comment">;; <code class="scheme"><span class="variable">outer</span></code> and whose hole has a radius of <code class="scheme"><span class="variable">inner</span></code></span><br>
<br><span class="comment">;; <u>Example</u>: <code class="scheme">(<span class="variable">area-of-ring</span> <span class="selfeval">5</span> <span class="selfeval">3</span>)</code> should produce 50.24</span><br><br><span class="comment">;; <u>Definition</u>: [refines the header]</span><br>
(<span class="keyword">define</span> (<span class="variable">area-of-ring</span> <span class="variable">outer</span> <span class="variable">inner</span>)<br>  (<span class="builtin">-</span> (<span class="variable">area-of-disk</span> <span class="variable">outer</span>)<br>
     (<span class="variable">area-of-disk</span> <span class="variable">inner</span>)))<br>  <br><span class="comment">;; <u>Tests</u>:</span><br>(<span class="variable">area-of-ring</span> <span class="selfeval">5</span> <span class="selfeval">3</span>) <br>
<span class="comment">;; expected value</span><br><span class="selfeval">50.24</span><br></pre><br>