Generally in Scheme - syntax: (if test consequent alternate) .
I trying to do some operations within the consequent section , for example : if true then set sum1 on 44 and return 1 .
In Scheme code its -
(if #t (
(set! sum1 44)
(if #t 1)
))
The above code doesn't works out and prompts -
application: not a procedure;
expected a procedure that can be applied to arguments
given: #<void>
arguments...:
1
In Scheme, parentheses are always used for application; you can't add extra parentheses for grouping.
Your consequent here is:
((set! sum1 44) (if #t 1))
The outer pair of parentheses makes Scheme attempt to use the result of (set! sum1 44) as a procedure, applying it to the result of (if #t 1).
What (I think) you want is to evaluate the two expressions in sequence, and then return the result of the last one. The form to do this is begin, so it should be:
(begin (set! sum1 44) (if #t 1))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With