Question: Haskell / Prolog. Please help, will upvote. [30 points: 15 points for each of the Haskell and Prolog implementations). Write a Haskell function evenLength ::
Haskell / Prolog. Please help, will upvote.
[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. [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
Get step-by-step solutions from verified subject matter experts
