
16 May
2005
16 May
'05
5:32 a.m.
Gracjan Polak
find (isSuffixOf "needle") (inits "haystack")
Hmm... While the result isn't exactly the same, I suspect using isPrefixOf and tails would be more efficient.
This one is beautiful, but not very practical.
Unless you have very repetitive data and/or tiny alphabet, it is actually quite efficient, as the expected length of prefixes that need to be checked before a mismatch can be determined is small. At least, I was unable to beat it with my (feeble attempts at) BM or KMP implementations. -kzm -- If I haven't seen further, it is by standing in the footprints of giants