[Haskell-cafe] Differences in optimisiation with interactive and compiled mo

Branimir Maksimovic bmaxa at hotmail.com
Fri Dec 9 04:24:16 EST 2005




>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.

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee® 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



More information about the Haskell-Cafe mailing list