{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ml.book.sols

# ml.book.sols - Exercise 2.1.1(a val it = 7 int Exercise...

This preview shows pages 1–4. Sign up to view the full content.

Exercise 2.1.1(a) val it = 7 ; int Exercise 2.1.1(c) val it = 2 : int We 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 : bool The andalso groups 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 : int Note that AB in hexadecimal is 171 in decimal. Exercise 2.1.2(a) The / operator applies only to reals, not integers. Use div instead. Exercise 2.1.2(c) The and operator has a meaning not discussed in Section 2.1; it cannot be applied to boolean values. Use andalso instead. 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

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document