Question: In Haskell Write a recursive function mytake, with the following type signature. mytake :: Int -> [String] -> [String] The function takes an Int n,

 In Haskell Write a recursive function mytake, with the following type

In Haskell

Write a recursive function mytake, with the following type signature. mytake :: Int -> [String] -> [String] The function takes an Int n, and returns the first n items in the list of strings. If n is zero, it returns an empty list. If n is greater than or equal to the length of the list, it returns the whole list. You may assume that n is non-negative. For example: * Main> mytake 2 ["first", "second", "third"] ["first","second"] * Main> mytake 100 ["first", "second", "third"] ["first","second","third"] * Main> mytake 0 ["first", "second", "third"] [] * Main> my take 2 [] [] * Main > my take 4 ["hi", "there", "test", "test", "whatever"] ["hi", "there","test", "test"] Hint: you can use the pattern [] to match an empty list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!