Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Haskell programming: Can anyone help me with this please ? thank you!! 3. We want a function count x xs which counts the number of
Haskell programming: Can anyone help me with this please ? thank you!!
3. We want a function count x xs which counts the number of times x occurs in the list xs (a) By now you should have no trouble writing a recursive version of this function in LISP or Haskell, so go ahead and provide such a recursive Haskell function. Also put t in a Haskell file asst4.hs . There will be a few other things you put in this file before submitting it as part of your homework. 2 (b) Show how to implement count x xs using length and a list comprehension. Show your definition below and put it in asst4.hs Solution: 4. The function zip to compute the pairwise interleaving of two lists of arbitrary length is predefined, but I'd like you to write it from scratch anyway (calling it zip'. *Main> zip' [1. .5] ['p..'t'] it: (Num a1, Enum al)-[(a1, Char)] *Main zip' [1.. 100] ['p*..] it :: (Num al, Enum a1) -[(al, Char)] *Main> zip' [1..5] ['a'.. 'z'] it :: (Nun al, Enum a1) => [(al, Char)] Note: If the lists don't have the same length, your function should behave the same way the built-in zip does Solution: 5. Using your zip', your count, and list comprehension(s), provide an implementation of freq (with type signature freq : Char] ->[(Char, Int)], which analyzes a string to produce a list of 2-tuples giving the frequency with which each lowercase letter in the alphabet occurs in str. Show your definition below and paste it into asst4.hs *Main> text "now is the time for all good women to come to the aid of the party because the quick brown fox just jumped over the lazy dog" text: [Char] *Main> freq text it [CChar, Int)]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