On Sat, Dec 10, 2005 at 03:29:49PM +0100, Tomasz Zielonka wrote:
> On Sat, Dec 10, 2005 at 03:24:56PM +0100, Tomasz Zielonka wrote:
> >     *SearchRepl> replace "ab" "ba" "aaaaaaaaab"
> >     "baaaaaaaaa"
> 
> It also shows that your implementation is not lazy, so it couldn't be
> used for infinite lists. In some situations, even for short patterns, it
> just has to check the whole input list to produce the first element of
> output list.

Here is my implementation

    replace src dst = repl
      where
        repl input = dst ++ repl (drop (length src) input)
        repl (x:xs) = x : repl xs
        repl [] = []

which should be infinite list friendly.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to