So I can not figure out why my numbers are negative in this function. Also, the input for calculate is supposed to be a list of the same 3 if someone could give me a hand with that as well, it would be much appreciated. Thank you.
calculate
takes the first number in the list, then multiplies it by the second number in the list and subtracts the third number from the input list.
((calculate '(8 3 7)) '(4 8 2 9))
should return '(29 41 23 44)
(define (calculateHelper n m o L)
(if (null? L) empty
(cons ((calculate n m o) (car L))
(calculateHelper n m o (cdr L)))))
;((calculate 8 3 7) '(4 8 2 9))
(define (calculate n m o)
(lambda (L)
(if (list? L) (calculate n m o L)
(- o (* m (+ n L))))))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…