Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

(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

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions