On Sun, Jan 2, 2011 at 2:05 PM, Todd O'Bryan <[email protected]> wrote:
> I believe Stephen was suggesting something like: > > ; net-pay: number -> number > ; given gross pay, produces net pay > (define (net-pay gross-pay) > (- gross-pay (tax gross-pay))) > > > On Sat, Jan 1, 2011 at 7:22 PM, Sayth Renshaw <[email protected]> > wrote: > > > > > > On Sun, Jan 2, 2011 at 6:05 AM, Stephen Bloch <[email protected]> > wrote: > >> > >> 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. > >> > >> Stephen Bloch > >> [email protected] > > > > 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 :-) > > > > (define (netpay hours) > > (* 12 hours)) > > > > (define (tax (netpay hours)) > > (cond > > [(<= netpay 240) 0] > > [(<= netpay 480) (* 0.15 netpay)] > > [(> netpay 480) (* 0.28 netpay)])) > > > > (define (mypay hours) > > (- (netpay hours)(tax hours))) > > > > _________________________________________________ > > For list-related administrative tasks: > > http://lists.racket-lang.org/listinfo/users > > > ; 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.
_________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

