Please code in Haskell: Problem 7 (5 marks) Write a function that given four arg
ID: 3879043 • Letter: P
Question
Please code in Haskell:
Problem 7 (5 marks) Write a function that given four arguments returns a triple of booleans representing the following: 1. Are the first and third argument equal? 2. Are the second and fourth argument equal? 3. Are all arguments equal? Problem 8 (5 marks) Using list comprehensions: 1. Write a function that takes a list of integers and doubles them. 2. Write a function that takes a list of numbers and returns a list of pairs where the first element of the pair is the original number, and the second element is the doubled value.Explanation / Answer
Problem 7:
import Data.Char
main = do
putStrLn "Please Enter first value"
first <- getLine --scan first input from user
putStrLn "Please Enter second value"
second <- getLine --scan second input from user
putStrLn "Please Enter third value"
third <- getLine --scan third input from user
putStrLn "Please Enter fourth value"
fourth <- getLine --scan fourth input from user
let (a1,b1,c1) = find a b c d --call the function
putstrLn ("First and third values are equal :" ++ a1 ++ " ") --print output
putstrLn ("Second and fourth values are equal :" ++ b1 ++ " ")
putstrLn ("All values are equal :" ++ c1 ++ " ")
--function
find :: (a,b,c,d) -> (a1,b1,c1)
if a==c then return true else return false --check for first and third number
if b==d then return true else return false --check for second and fourth number
if (a==b && b==c && c==1) then return true else return false --whether all numbers are equal