Question: In Haskell, What is the source code of FindIndex function ? (not using library functions) It finds the index of the first argument of the

In Haskell,

What is the source code of FindIndex function ? (not using library functions)

It finds the index of the first argument of the function in the list, which is the second argument. And return its first index as a list.

FindIndex :: (Eq a) => a -> [a] -> [Integer]

FindIndex _ [] = []

FindIndex a (x:xs)

| a == x = return index of x ...

| otherwise = FindIndex a xs ...

ex. FindIndex 2 [4, 5, 10, 2] = [3]

, FindIndex "e" "agdfeg" = [4]

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!