Zip Two Lists into Typed Pairs

Write the code, see it run, pass the checks.

The problem

  • easy
  • Code

Write zip(a, b): pair the items of two lists by position, giving [a[0], b[0]], [a[1], b[1]] and so on, and stop at the end of the shorter list. Type it so each pair is a tuple of the two lists' item types, in order, so a list of ids zipped with a list of names gives [number, string][], never (number | string)[][] or any.

Your code must pass

  • Pairs items by position
  • Stops at the shorter list
  • Has no type errors
  • Pairs are typed [A, B]
  • Rejects pairs used the wrong way round