Hi, On Tue, Feb 21, 2012 at 12:49, Roelof Wobben <[email protected]> wrote:
> I have this script : > > (define (nettoloon h) > ( - (brutoloon h) (belasting h))) > > (define (belasting h) > (cond > [(< (brutoloon h) 240) (* 0 (brutoloon h))] > [(and (< (brutoloon h) 480) (> (brutoloon h) 240)) ( * 0.15 (brutoloon > h))] > [else ( * 0.28 ( nettoloon h))])) > > (define (brutoloon h) > (* 12 h)) > > But it seems there a error in belasting. > When I do (belasting 239) I don't get a answer but a memory error problem. > And I don't see why this happens. > > Can anyone help me finding out what is wrong here ? > > In computing (belasting 239) the first 2 cond-clauses are false, then in the else clause you compute (nettoloon 239). In computing (nettoloon 239) you need to compute (belasting 239) again, and so you get into an infinite loop. If you use one of the Student languages, you can use the Stepper to see step-by-step what is going on. []'s Rodolfo
____________________ Racket Users list: http://lists.racket-lang.org/users

