
8 Jun
2010
8 Jun
'10
4:46 a.m.
R J
What's an elegant definition of a Haskell function that takes two strings and returns "Nothing" in case the first string isn't a substring of the first, or "Just i", where i is the index number of the position within the first string where the second string begins?
f n h = listToMaybe [b | (a,b)<- tails h `zip` [1..], n `isPrefixOf` a] seems plausible, but how do you define elegant? -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk