Skip to content

Instantly share code, notes, and snippets.

@jjlumagbas
Created September 8, 2016 04:11
Show Gist options
  • Save jjlumagbas/2245ea4266a5552823017458c93c2782 to your computer and use it in GitHub Desktop.
Save jjlumagbas/2245ea4266a5552823017458c93c2782 to your computer and use it in GitHub Desktop.
-- from Don Sanella
-- http://www.inf.ed.ac.uk/teaching/courses/inf1/fp/
searchRec :: Eq a => [a] -> a -> [Int]
searchRec xs y = srch xs y 0
where
srch :: Eq a => [a] -> a -> Int -> [Int]
srch [] y i = []
srch (x:xs) y i
| x == y = i : srch xs y (i+1)
| otherwise = srch xs y (i+1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment