Question: Write a simple Haskell function elementPosition :: Eq t => t -> [t] -> Int elementPosition takes an element elt and a list lst, and

Write a simple Haskell function

elementPosition :: Eq t => t -> [t] -> Int elementPosition takes an element elt and a list lst, and returns the position of the rst occurrence of elt in lst. That is, it returns the one-based index of the rst occurrence of elt on lst. If elt does not appear in the list lst it should return 0. For example: elementPosition 3 [1,2,3,4,5] should return 3 elementPosition 'e' "elephant" should return 1 elementPosition 'p' "elephant" should return 4 elementPosition 'z' "elephant" should return 0

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!