8. Walkthrough I

A sequence of short exercises to become familiar with the first half of constructors.
  1. Make AList mean [Int].
  1. Write a function (ao) that takes in an AList and puts out an Int. The ao function adds up all of the odd numbers in the list. Include signature.
  1. Make WP (for “word pair”) mean (String, String).
  1. Write a function (ce) counting how many times the two strings are equal in a list of WP. Include signature.
  1. Make a data type called Celsius that holds a Float measuring the temperature.
  1. Make a similar data type called Fahrenheit.
  1. (tempchange) Make a function that converts Celsius to Fahrenheit according to the rule (f = 9/5 c + 32).
  1. Names: Surname is a String, and GivenName is a String. Make two data types, one for each.
  1. The marry function takes two Surname and combines them with a hyphen to create a new Surname. Write the signature and function.
  1. Beginning with the Point definition below, write a d0 function measuring the distance to the origin.

    data Point = Origin | Point Float Float

  1. Make a datatype Drink which is Water or Gatorade.
  1. Make a calories function that converts Drink to Int calories. Water is 0, Gatorade is 15. Include a signature.