[racket] Defining Variables in a function

From: Sayth Renshaw (flebber.crue at gmail.com)
Date: Sun Jan 2 21:55:52 EST 2011

On Mon, Jan 3, 2011 at 1:19 AM, Stephen Bloch <sbloch at adelphi.edu> wrote:

>
> > ; net-pay: number -> number
> > ; given gross pay, produces net pay
> > (define (net-pay gross-pay)
> >  (- gross-pay (tax gross-pay)))
> >
> > Ah okay, I was using hours as the only user input to have a whole
> function calculate netpay of one input.
>
> Yes, you should still do that.  The above is just a helper function (like
> "pay"); it's not the function you tell the users about.  Perhaps a better
> name for it would be "deduct-tax", leaving the original name "net-pay" free
> to be used for the function that takes in hours and returns net pay.
>
> Stephen Bloch
> sbloch at adelphi.edu
>


Unfortunately I think I must be blind to this solution, I have done the
exercises after and had no problem. I have re-writeen this one too many
times I have lost focus.

This is where I was embedding a function again.


(define (gross hours)
  (* 12 hours ))
(define (pay (gross hours))
  (cond
    [(>= gross 480) (+(*(- gross 480)0.28)36)]
    [(>= gross 240) (*(- gross 240)0.15)]
    [(< gross 240) 0]))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110103/2e5e4a42/attachment.html>

Posted on the users mailing list.