Question: 6. Write a Haskell function changeFirst: (a Bool) ->a > [a] > a] such that changeFirst p val xs returns a list that looks like

 6. Write a Haskell function changeFirst: (a Bool) ->a > [a]

6. Write a Haskell function changeFirst: (a Bool) ->a > [a] > a] such that changeFirst p val xs returns a list that looks like xs except that the leftmost item in xs that satisfies predicate p is replaced by val Here are some examples Main> changeFirst even 33 01,7,4,8,2 01,7,33,8,2 *Main> changeFirst even 33 [1,7,9,5] 01,7,9,5 Main> changeFirst isLower'"Syracuse "S!racuse Main> changeFirst isLower'SYRACUSE "SYRACUSE" 6. Write a Haskell function changeFirst: (a Bool) ->a > [a] > a] such that changeFirst p val xs returns a list that looks like xs except that the leftmost item in xs that satisfies predicate p is replaced by val Here are some examples Main> changeFirst even 33 01,7,4,8,2 01,7,33,8,2 *Main> changeFirst even 33 [1,7,9,5] 01,7,9,5 Main> changeFirst isLower'"Syracuse "S!racuse Main> changeFirst isLower'SYRACUSE "SYRACUSE

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!