문제

I read a book that uses infix, infixr, and infixl in the sample programs. I'm wondering what the differences are. I'm guessing that infixr performs operation from right to left, and vice versa.

도움이 되었습니까?

해결책

Yes, the r/l indicates the associativity. Without testing I'd assume that infix has normal left associativity.

다른 팁

infix defines the operator to be left-associative, infixr defines it to be right-associative. infixl does not exist.

It depends on the implementation. The SML '97 standard is a little different from SML/NJ and Mlton. You get slightly different behaviour with each in terms of associativity rules and the way expressions are parenthesised depending on priority (the standard is a bit stricter than the implementations).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top