[racket] Defining Variables in a function

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Sun Jan 2 09:19:45 EST 2011

> ; 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

Posted on the users mailing list.