RE: [REBOL] Re: newlines

Hi Joel,

another copy-style to benchmark :-)

        out: clear ""
        parse/all s [any [
                        start: thru "..." end1: any "."
                        (insert/part tail out start back end1)
                ]]
        insert tail out start
        out
        ; or [head insert clear s out] or [copy out]

here is also an in-place solution, but that is 20 times slower?!

        out: s
        parse s [any [
                        start: thru "..." end1: any "."
                        (
                                change/part out start back end1
                                out: skip out subtract index? back end1 index? start
                        )
                ]]
        change out start
        clear skip out length? start
        s

-Volker

[EMAIL PROTECTED] wrote:
> 
> Ladislav Mecir wrote:
> >
> > Hi Joel,
> >
> > I will try to add my 0,02 CZK.
> >
> 
> ~LOL!  Pardon my ignorance, but can you expand the acronym?
> 
> CZK = is an international (AFAIK) shortcut for Czech Crown (Ceska Koruna,
> alias Kc)
> 
> >
> > a) there is another disadvantage to the COPY algorithm you
> >    didn't mention.  It is not an in-place algorithm and that
> >    is why it needs more memory.
> >
> 
> Thanks for pointing that out.  I usually work on big-memory
> boxen and don't think of that often enough.
> 
> Yet another classic time-vs-space tradeoff!
> 
> Actually, there is an easy way how to change it to an in-place algorithm. A
> Finite State Machine might be ideally suited for that.
> 
> >
> > b) Some algorithms are complicated, that is why a different
> > approach (not using REPLACE) should be considered too:
> >
> >     while [s: find s #"."] [
> >         parse next s [any #"." t:]
> >         s: either (index? s) + 2 < (index? t) [
> >             remove/part skip s 2 t
> >         ] [t]
> >     ]
> >
> 
> Thanks!  I'll add this to the benchmark, along with Brett's
> latest versions, and report results when done.
> 
> -jn-
> 
> --
> We say "gestalt" when things combine to act in ways we can't
> explain.
>                                                     -- Marvin Minsky
> joel/dot/neely/at/fedex/FIX/PUNCTUATION/dot/com
> 
> 
> -- 
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the 
> subject, without the quotes.
> 
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to