Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 Programmingimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions