[racket] Basic Racket Question

 From: Sayth Renshaw (flebber.crue at gmail.com) Date: Tue Dec 21 19:55:48 EST 2010 Previous message: [racket] else: not allowed as an expression in: else Next message: [racket] Basic Racket Question Messages sorted by: [date] [thread] [subject] [author]

```On Wed, Dec 22, 2010 at 11:54 AM, Sayth Renshaw <flebber.crue at gmail.com>wrote:

>
>
> On Wed, Dec 22, 2010 at 11:39 AM, Sam Griff <sgriff89 at gmail.com> wrote:
>
>>
>> You need to start over and slow down because you are getting the basic
>> Scheme syntax wrong.
>> The gross pay function is already given:
>> (define (wage h)
>>  (* 12 h))
>>
>> You could modify it according to the previous suggestions to make it more
>> ; By convention constants are named in upper case
>>  (define TAX-RATE 0.15)
>>  (define PAY-RATE 12)
>>
>> (define (wage h)
>>  (* PAY-RATE h))
>>
>> Where did your tax function go? How could you use tax and wage to develop
>> netpay?
>>
>>
>>  (define (gross hours)
>>    (* hours pay-rate))
>>
>>  (define (netpay gross tax-rate)
>>    (-(gross)(* gross tax-rate)))
>>
>> Has a few major issues: 1) You have defined gross to take one argument but
>> when you "call" it from (my 2nd point) you have provided no arguments and 2)
>> you have named a "gross" parameter in netpay and use it twice. Which "gross"
>> do you think is being used? The function or the passed value?
>>
>> Also:
>>
>> (define (netpay hours : number? tax : 0.85)
>>   (* hours 12)* tax)
>>
>> Where did you get that syntax from? Follow the examples in the book.
>> Additionally, that is not even the right formula for computing netpay.
>> Follow the development of functions for the exercise exactly and the proper
>> formula should be clear.
>>
>
> The main problem I am having is that I followed the examples in the book
> without issue until I hit this example, something about it is throuwing me.
>
> To cover off Danny's post
>
> the error I am seeing is
>
>
> f*unction call: expected a defined function name or a primitive operation
> name after an open parenthesis, but found a function argument name*
>
> I will explain in numbers what i expect gross to do and maybe that will
> make my operation clearer. I had defined gross as hours multiply pay rate.
>
> So pay rate in example was \$12 and lets say I worked 20 hrs. my gross = 240
>
>
>  (define (netpay gross tax-rate)
>    (-(gross)(* gross tax-rate)))
>
> So I expect the function to calculate as
>
> = (-(240)(* 240 0.15)
> = ( - 240 36)
> = 204
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101222/17d8fdf2/attachment.html>
```

 Posted on the users mailing list. Previous message: [racket] else: not allowed as an expression in: else Next message: [racket] Basic Racket Question Messages sorted by: [date] [thread] [subject] [author]