Re[2]: [Haskell-cafe] Text search

2005-05-17 Thread Bulat Ziganshin
Hello Gracjan, Monday, May 16, 2005, 4:00:33 PM, you wrote: GP Unless you have very repetitive data and/or tiny alphabet, it is GP actually quite efficient, as the expected length of prefixes that need GP to be checked before a mismatch can be determined is small. GP GP At least, I was

RE: Re[2]: [Haskell-cafe] Text search

2005-05-17 Thread Bayley, Alistair
From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] if you really need KMP, you can find it at http://haskell.org/hawiki/RunTimeCompilation find (isSuffixOf needle) (inits haystack) find (isPrefixOf needle) (tails haystack) if you need an index - add it with zip: find (isPrefixOf

Re: [Haskell-cafe] Text search

2005-05-17 Thread Scott Kathy
On 2005 May 16 Monday 08:00, Gracjan Polak wrote: Ketil Malde wrote: While the result isn't exactly the same, I suspect using isPrefixOf and tails would be more efficient. I need the data before and including my needle. When the haystack gets large, the beautiful find (isSuffixOf

Re: [Haskell-cafe] Text search

2005-05-17 Thread Donn Cave
You can get efficiency, the desired data, and deal with infinite strings by using a function that is like 'inits' but which returns the initial strings in reversed order. reversed_inits = scanl (flip (:)) find (isPrefixOf (reverse needle)) (reversed_inits haystack) If I may ask

Re: [Haskell-cafe] Text search

2005-05-17 Thread Scott Turner
On 2005 May 17 Tuesday 11:44, Donn Cave wrote: You can get efficiency, the desired data, and deal with infinite strings. reversed_inits = scanl (flip (:)) find (isPrefixOf (reverse needle)) (reversed_inits haystack) With get efficiency, I was comparing this program which is linear

[Haskell-cafe] Text search

2005-05-16 Thread Gracjan Polak
Hi, Simple question: I need a function that matches string in another string. Something like: find (isSuffixOf needle) (inits haystack) This one is beautiful, but not very practical. Could anybody point me to some haskell library that does some searching, using KMP for example? -- Gracjan

Re: [Haskell-cafe] Text search

2005-05-16 Thread Ketil Malde
Gracjan Polak [EMAIL PROTECTED] writes: 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

Re: [Haskell-cafe] Text search

2005-05-16 Thread Graham Klyne
At 10:27 16/05/05 +0200, Gracjan Polak wrote: Hi, Simple question: I need a function that matches string in another string. Something like: find (isSuffixOf needle) (inits haystack) This one is beautiful, but not very practical. Could anybody point me to some haskell library that does some

Re: [Haskell-cafe] Text search

2005-05-16 Thread Gracjan Polak
Ketil Malde wrote: Gracjan Polak [EMAIL PROTECTED] writes: find (isSuffixOf needle) (inits haystack) Hmm... While the result isn't exactly the same, I suspect using isPrefixOf and tails would be more efficient. I need the data before and including my needle. Like this: ( ... needle )

Re: [Haskell-cafe] Text search

2005-05-16 Thread Scott Turner
On 2005 May 16 Monday 08:00, Gracjan Polak wrote: Ketil Malde wrote: While the result isn't exactly the same, I suspect using isPrefixOf and tails would be more efficient. I need the data before and including my needle. When the haystack gets large, the beautiful find (isSuffixOf

Re: [Haskell-cafe] Text search

2005-05-16 Thread ajb
G'day all. Quoting Gracjan Polak [EMAIL PROTECTED]: Simple question: I need a function that matches string in another string. Something like: find (isSuffixOf needle) (inits haystack) This one is beautiful, but not very practical. This one is fairly practical, but not very beautiful: