Do operators in the Scheme programming language have associativity. For example, the code (- 5 2 1) evaluates to 2, but it could evaluate to 4 if it was evaluated right-associative. However, it is unambiguous if you were to write the expression as (- (- 5 2) 1). The first example, however, leads me to believe that Scheme is left-associative in the case that you do not group all operations into only two arguments at a time.
Do Scheme operators have associativity?
programming languages
Scheme computes (- a b c) as a - b - c, i.e., strictly left to right.It really makes no sense to talk about associativity in Scheme, which applies to how an otherwise ambiguous expression like a # b # c is to be interpreted, either as (a # b) # c or a # (b # c) (or even forbid such combinations). In Scheme no such ambiguity is possible, everything is prefix. And the function called is responsible to decide what to do with it's arguments, even if the number of arguments is variable (as in this case). It is probably more natural to work left-to-right.