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]](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3c60167b07_96866f3c600e008b.jpg)
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
Get step-by-step solutions from verified subject matter experts
