On Wed, Dec 22, 2010 at 1:02 PM, Danny Yoo <[email protected]> wrote: > >> (define (netpay gross tax-rate) > >> (-(gross)(* gross tax-rate))) > >> > >> So I expect the function to calculate as > >> > >> = (-(240)(* 240 0.15) > >> = ( - 240 36) > >> = 204 > > > Just to be more careful: when you're showing the calculation, make > sure to include the use of the function: > > (netpay 240 0.15) > = (-(240)(* 240 0.15) > = ( - 240 36) > = 204 > > > There's a hitch on the first step in the calculation, and it has to do > with the parens. Unlike its use in traditional math notation, parens > are significant in this language: that is, every use of paren has to > mean something: it's not superfluous: if you have too many or too few, > it changes the meaning of the program. > > > So, within the larger term here: > > (- (240) (* 240 0.15)) > > the subterm > > (240) > > means "call the function 240". That may not be what you intend, but > that what it means in this language. > > > You can see this if you go back to what the error message is saying: > > function call: expected a defined function name or a primitive > operation name after an open parenthesis, but found a function > argument name > > It's basically trying to point out this problem, that the use of > "(gross)" within the expression > > (-(gross)(* gross tax-rate)) > > is trying to use gross as if it were a function, rather than the > numeric argument to netpay. >
the subterm (240) means "call the function 240". That may not be what you intend, but that what it means in this language. Awesome pickup, thank you. Can I ask how I could then specify gross a single item in the formula and not as a function?
_________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

