Reputation: 783
I need help in adding the multiplication of values with variables and assigning these to a variable in Scheme.
for example I have..
(define overall 0)
(define part1 0.15)
(define part2 0.20)
(define part3 0.4)
(define usrInput1 0)
(define usrInput2 0)
..
I need to do something like
overall = usrInput*part1 + usrInput*part2 + part3
in Scheme
I know how to add 2 variables/scalars together, but here I am stuck, could you please advise...
thank you.
Upvotes: 0
Views: 8244
Reputation: 370162
Remove the (define overall 0)
. Then define overall
to be the expressions you gave, except in (fully parenthesized) prefix notation instead of infix:
(define overall (+ (* usrInput1 part1) (* usrInput2 part2) part3))
The syntax to call any function/operator call in scheme is (operator-name operand1 operand2 ... operandn)
, not matter whether the operands are scalars, variables or nested expressions.
Upvotes: 2