Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(30 points: 15 points for each of the Haskell and Prolog implementations). Write a Haskell function evenLength :: [a] Bool and the corresponding Prolog predicate
(30 points: 15 points for each of the Haskell and Prolog implementations). Write a Haskell function evenLength :: [a] Bool and the corresponding Prolog predicate evenLength, which returns (or resolves to) true when the single list argument passed to it has even length. Note: that these must be written from scratch, so no previously defined functions may be used, e.g., the Prelude length function (or the Prolog length predicate) may not be used - your solutions will be recursive. You may, of course define auxiliary helper functions (which also must be written from scratch), e.g., the appropriate oddlength :: [a] -> Bool might be useful in Haskell, and similarly, an oddLength predicate in Prolog. The idea is that in Haskell, e.g., evenLength [1,2,3,4] would return True, and evenLength "hey" would return False, while in Prolog, e.g., the query evenLength([1,2,3,4]). would resolve to true, and the query evenLength ([a,b,c]). would resolve to false
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started