Perfect Developer basic tutorial 3 This page last modified 2011-10-29 (JAC)

Sequences Quiz

1. Simplify the following expressions, assuming that x and y are sequences, i, j and k are integers and that all indices and parameters are in bounds:

  1. seq of int{i, j, k}[1]
  2. x.drop(i).take(j) [Hint: use the slice member function]
  3. x.take(i)[j]
  4. x.drop(i)[j]
  5. x.drop(i).head
  6. x.take(i).last
  7. (i..j)[k]
  8. (x ++ y)[i] [Hint: use a conditional expression]
  1. j
  2. x.slice(i, j)
  3. x[j]
  4. x[i + j]
  5. x[i]
  6. x[i - 1]
  7. i + k
  8. ([i < #x]: x[i], []: y[i - #x])