Roelof Wobben writes:
> Does anyone have a simple example how I can take care that the value
> of function1 get used in function2.
Either you pass the value of function1 to function2 when you call
function2, or you call function1 in the body of the procedure that
implements function2.
The reason to the error message you mentioned is explained by Eli
Barzilay in a recent followup to me: you are using the beginner
setting of Racket, which does not allow procedures as values. You may
not even understand the phrase "procedures as values" yet.
You have seen two different notations for functions in calculus. One
is like y = x^2 + 1, where the parameter x is implicit in y, and the
other is like f(x) = x^2 + 1, where the parameter x is explicit in
f(x). I think you tried to use the former convention and got stuck.
Better use the latter when programming.
Something like this should work:
(define (h x) (- (f x) (g (f x))))
(define (g x) (* x 0.15))
(define (f x) (* x 12))
And when you learn about let and let*, you can improve on it a bit, as
suggested by Fyndhor Elder, or with your current machinery you can use
the fact that x - 0.15 * x = 0.85 * x.