20-CS-4003-001 Organization of Programming Languages Fall 2018
Lab Assignment 9

Lambda calculus, Type theory, Formal semantics, Program analysis

Hamming's Sequence

Due: 5 November, 2018 (submit instructions: here)

    Simple warmup exercise.
Lab Problem (three parts):
1. Create a haskell procedure called merge that takes as input two (possibly infinite) lists of increasing integers and outputs a single increasing sequence consisting of all the numbers in the two input lists. For example, if the input lists are
   *Main> merge [3,7,8,12,89] [1,2,8,9,19,22]

2. Create a haskell procedure called times that takes as input a positive integer m and a list of integers L and outputs a list of integers, each of which is m times its position counterpart in L. For example

   *Main> times 3 [4,8,9,16]

3. Create a haskell procedure called hamming that takes as input an increasing list P of prime numbers and outputs all integers whose prime factors are a subset of P, in increasing order. For example

   *Main> take 20 (ham [3,5,11])
Observe take must be used or else haskell attempts to print the entire (infinite) list.