Exercise 2.1.1(a) val it = 7 ; intExercise 2.1.1(c) val it = 2 : intWe group operators from the left, so we first evaluate 11 div 2, or 5, and then evaluate 5 mod 3, which is 2. Exercise 2.1.1(e) val it = false : boolThe andalsogroups its operands before the orelse. Thus, the whole expression is grouped 3>4 orelse (5<6 andalso (not 7<>8)) Exercise 2.1.1(g) val it = 294 : intNote that AB in hexadecimal is 171 in decimal. Exercise 2.1.2(a) The / operator applies only to reals, not integers. Use divinstead. Exercise 2.1.2(c) The andoperator has a meaning not discussed in Section 2.1; it cannot be applied to boolean values. Use andalsoinstead. Exercise 2.1.2(e) A real number needs to have digits both before and after the decimal point. Instead of 4., use 4.0. Exercise 2.1.2(g) The concatenation operator ^ applies to strings, not characters. "a"^"b"would be correct. Exercise 2.1.2(i) Real numbers may not be compared using =or <>. A legal equivalent would be 1.0 <= 2.0 andalso 2.0 <= 1.0
has intentionally blurred sections.
Sign up to view the full version.