Question: Haskell Programming 3. (18 points total) The function twice list should return true iff some value occurs twice in the list. E.g., > filter twice
Haskell Programming
3. (18 points total) The function twice list should return true iff some value occurs twice in the list. E.g., > filter twice [[],[1],[1,2], [2,2],[1,2,3],[1,2,1],[1,1,2], [1,2,2]] [[2,2],[1,2,1],[1,1,2],[1,2,2]] (2 points) What is the type of twice? (Include the typeclass.) a. (4 points) Briefly describe the syntactic and semantic bugs in the program below. (For syntactic errors, don't just parrot the Haskell error messages; give a brief human-understandable description.) :{ twice [] = False twice [_] = False twice [x,x] = True twice ( _ ++ [x] ++ - ++ [y] ++ _ ) = x == y twice (h1 : h2 : t) == (h1 == h2 || twice hi t) 3. (18 points total) The function twice list should return true iff some value occurs twice in the list. E.g., > filter twice [[],[1],[1,2], [2,2],[1,2,3],[1,2,1],[1,1,2], [1,2,2]] [[2,2],[1,2,1],[1,1,2],[1,2,2]] (2 points) What is the type of twice? (Include the typeclass.) a. (4 points) Briefly describe the syntactic and semantic bugs in the program below. (For syntactic errors, don't just parrot the Haskell error messages; give a brief human-understandable description.) :{ twice [] = False twice [_] = False twice [x,x] = True twice ( _ ++ [x] ++ - ++ [y] ++ _ ) = x == y twice (h1 : h2 : t) == (h1 == h2 || twice hi t)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
