Question: Haskell function that will replace all occurrences of a in list with b. Write the function replace :: Eq a => a -> a ->

Haskell function that will replace all occurrences of a in list with b.

Write the function replace :: Eq a => a -> a -> [a] -> [a]. The application replace a b list will replace all occurrences of a in list with b.

For example:

replace a X "abcabAcdaee" ? "XbcXbAcdXee"

replace 1 100 [2,3,1,1,5,6] ? [2,3,100,100,5,6]

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!