<br><br><div class="gmail_quote">On Sun, Jan 2, 2011 at 6:05 AM, Stephen Bloch <span dir="ltr"><<a href="mailto:sbloch@adelphi.edu">sbloch@adelphi.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;">
Another solution, which doesn't require any language features you don't know yet, is to write a helper function that takes in the gross pay and computes the net pay from it. Your main function then calls this new helper function on the result of your "pay" function. The "pay" function is called only once, and your new helper uses the result twice.<br>
<font color="#888888"><br>
Stephen Bloch<br>
<a href="mailto:sbloch@adelphi.edu">sbloch@adelphi.edu</a></font></blockquote></div><br><br>I can't quite get it to happen at the moment. But is this more the style you were referring to...However it doesn't like me embedding one function in the definition of another. will have to keep thinking :-)<br>
<br>(define (netpay hours)<br> (* 12 hours))<br><br>(define (tax (netpay hours))<br> (cond<br> [(<= netpay 240) 0]<br> [(<= netpay 480) (* 0.15 netpay)]<br> [(> netpay 480) (* 0.28 netpay)])) <br> <br>
(define (mypay hours)<br> (- (netpay hours)(tax hours)))<br>