# [racket] Basic Racket Question

 From: Sayth Renshaw (flebber.crue at gmail.com) Date: Tue Dec 21 17:43:33 EST 2010 Previous message: [racket] Basic Racket Question Next message: [racket] Basic Racket Question Messages sorted by: [date] [thread] [subject] [author]

```On Wed, Dec 22, 2010 at 2:04 AM, Stephen Bloch <sbloch at adelphi.edu> wrote:

>
> On Dec 21, 2010, at 6:50 AM, Sayth Renshaw wrote:
>
> > Doing the netpay of employee tax = 0.15 and pay = hrs *12. From the
> beginner tutorial. I see two ways a simple and a hard way but neither work.
> >
> > Hard  way
> >
> > (define (hours h)
> >   (h : number?))
> > (define (tax t)
> >   (= t 0.15))
> > (define (payrate p)
> >   (= p \$12.00))
> > (define (netpay hours tax payrate)
> >   (* h p)-(* t(* h p)))
>
> Something else I forgot to mention in my previous message: you're quite
> right to want to give names to the tax rate and the hourly pay.  The usual
> way to do this in Beginner Racket would be
>        (define tax-rate 0.15)
>        (define pay-rate 12)
> Note that these definitions are OUTSIDE the definition of "netpay".
>
> You can then use these in functions you define.  For example, the
> "inventory" step of this function definition would become
>         (define (netpay hours)
>                ; hours                 a number
>                 ; pay-rate              a number (\$/hour)
>                ; tax-rate                      a number
>                ...
>                )
> and then the body could use all three of these variable names.
>
> Later in the book, you'll learn another way to do it, using "local
> variables" so the names "tax-rate" and "pay-rate" are visible only INSIDE
> "netpay":
>        (define (netpay hours)
>                (local [(define tax-rate 0.15)
>                            (define pay-rate 12)]
>                        ; hours         a number
>                        ; tax-rate              a number
>                        ; pay-rate      a number (\$/hour)
>                        ...
>                ))
> This version doesn't work in Beginning Student Language, though; you need
> Intermediate Student Language.
>
>
>
>
> Stephen Bloch
> sbloch at adelphi.edu
>
>
Firstly thank you very much for the feedback and ideas its very appreciated.

I am following the book again and your examples but i am rewriting examples
so I am learning it.

I came to this as a solution based on feeedback but it is erroring on the
word gross as part of my netpay function. Do i need to define the gross
function in my netpay function?

(define tax-rate 0.15)
(define pay-rate 12)
(define (gross hours)
(* hours pay-rate))

(define (netpay gross tax-rate)
(gross (- tax-rate)))

Not quite grabbing something intrinsic,  unfortunately Norman this is the
start of the book..If I have defined gross function as suggested earlier why
can't my netpay function use it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101222/3b8f8185/attachment.html>
```

 Posted on the users mailing list. Previous message: [racket] Basic Racket Question Next message: [racket] Basic Racket Question Messages sorted by: [date] [thread] [subject] [author]