-- Informatics 2A Assignment 1, Nov 2016 -- MH test program 3 -- Representing infinite lists of booleans as functions head :: (Integer -> Bool) -> Bool ; head l = l 0; tail :: (Integer -> Bool) -> (Integer -> Bool) ; tail l n = l(n+1) ; cons :: Bool -> (Integer -> Bool) -> Integer -> Bool ; cons n l m = if m == 0 then n else l(m - 1) ; inTeens :: Integer -> Bool ; inTeens n = if 13 <= n then n <= 19 else False ; -- Test expression: (if (cons False inTeens) 13 then 2 else 0) + (if (head (tail inTeens)) then 0 else 1) -- Type should be: Integer -- Value should be: 1