Search for question
Question

1. a)Write a program that allows a user to select a number between 1 and 5 and then prints a

famous quote (quotes are of your choosing). After printing the quote, the program will

ask whether the user would like another. If the user enters n, the program ends; otherwise,

the user gets another quote. The program repeats until the user enters n. Try to use lazy

evaluation and treat the user input as a list rather than recursively calling main at the end.

b)

The following Haskell functions each take predicate function and a list as input and

remove certain items from the list based on the predicate function. They each have this

signature:

(a -> Bool) -> [a] -> [a]

a. Itrim removes all items from the start of the list that satisfy the predicate function.

b. rtrim removes all items from the end of the list that satisfy the predicate function.

c. trim removes all items from both the start and end of the list that satisfy the predicate

function.

Implement these functions and demonstrate the result.

Fig: 1