[Haskell-cafe] Re: Differences in optimisiation with interactive
and compiled mo
Daniel Fischer
daniel.is.fischer at web.de
Fri Dec 9 17:27:00 EST 2005
Still doesn't work, though:
*Main> searchr "hahal" "jupp" "hahahalala"
"hahahalala"
The problem is that the string to replace may contain a repeated pattern
and the pattern that begins the actual occurence might be consumed before a
failure is detected.
And is
*Main> searchr "bla" "" "remove bla bla"
"remove bla bla"
really intended?
Cheers, Daniel
Am Freitag, 9. Dezember 2005 10:24 schrieb Branimir Maksimovic:
> From: Henning Thielemann <lemming at henning-thielemann.de>
>
> >To: Branimir Maksimovic <bmaxa at hotmail.com>
> >CC: haskell-cafe at haskell.org
> >Subject: Re: [Haskell-cafe] Differences in optimisiation with interactive
> >and compiled mo
> >Date: Fri, 9 Dec 2005 09:23:53 +0100 (MET)
> >
> >On Thu, 8 Dec 2005, Branimir Maksimovic wrote:
> >>>From: Henning Thielemann <lemming at henning-thielemann.de>
> >>>To: Branimir Maksimovic <bmaxa at hotmail.com>
> >>>CC: haskell-cafe at haskell.org
> >>>Subject: Re: [Haskell-cafe] Differences in optimisiation with
> >>> interactive and compiled mode
> >>>Date: Thu, 8 Dec 2005 18:38:45 +0100 (MET)
> >>>
> >>>On Thu, 8 Dec 2005, Branimir Maksimovic wrote:
> >>> > program performs search replace on a String
> >>>
> >>>http://www.haskell.org/pipermail/haskell-cafe/2005-April/009692.html
> >>
> >>This is nice and ellegant but example search replace program runs more
> >>then 50% faster with my implementation.
> >
> >Is this intended:
> >
> >*SearchReplace> searchr "ha" "lo" "hha"
> >"hha"
> >
> >?
>
> thanks, this is a bug. I over optimised it :)
> that should be :
> searchr'' (sr:srs) (x:xs) fndSoFar s | sr == x = searchr'' srs xs
> (x:fndSoFar) s
>
> | otherwise = (False,searchr''' s
> | (x:xs)
>
> fndSoFar)
>
> instead of
> searchr'' (sr:srs) (x:xs) fndSoFar s | sr == x = searchr'' srs xs xxs s
>
> | otherwise = (False,searchr''' s xs
>
> xxs)
> where xxs = x:fndSoFar
>
> Just to say my algorithm takes some optimisation opportunities.
> For example if "search" "replace" " able search baker search charlie " then
> it will run much
> faster then if " able sssssssssssssssssearch baker search charlie "
> Worst case is repetitive first mathing character, but than it is fast
> as normal implementation.
>
> Greetings, Bane.
>
More information about the Haskell-Cafe
mailing list