Exercise 1          Name _____________________  Pts ___/12

Write the functions that return the following results:

  1. g)inc 4 returns 5;


    hM
  2. Modulus operation

    modulus(5,2)
    returns 1
    modulus(14,3) returns 2
    modulus(12,4) returns 0

    Note the use of a parameter tuple requires the function to be defined as:

        fun modulus (a,b) = ...
     
  3. Euclid's Algorithm for greatest common denominator

    gcd(13, 5)
    the greatest common divisor, returns 1
    gcd(10,4) returns 2
    gcd(36,15) returns 3
     
  4. second ["hello","world"]; returns "world"
    second [4, 5, 3];
    returns 5

     
  5. i)smallest [5, ~4, 3]; returns ~4

       
  6. j)snoc 3 [4,5] returns [4, 5, 3]

    Note the use of two parameters requires the function to be defined as:

        fun snoc a L = ...