Skip to main content

Section 3.6 Builtins: Practice problems

This section should ideally have a more organized set of problems. Alas, I have no time to create them at the moment. So for now, here some problems to think about:
  1. Make a function which is given via a parameter a list of numbers, and which returns the sum of those numbers.
  2. Make a function which is given via a parameter of list of numbers, and which returns the "range" of the numbers (largest minus smallest).
  3. Make a function which is given a number n and returns a list of the numbers from 1 to n.
  4. Make a function which is given a string of words, and it concatenates these words separated by spaces, and returns the concatenation. It must not contain an extra space at the beginning or end.
  5. Make a function like above, except it is given a second parameter of a separator string, and it uses that separator instead of spaces.
  6. Make a function that is given a map of string keys and integer values. It then returns a list of strings, where each string key shows up in that list for the number of times specified in the map. For example if the map had the key "a" with value 3 and the key "b" with value 2, then the resulting list would contain 3 "a"s and 2 "b"s.