[REBOL] Re: newlines
From: lmecir:mbox:vol:cz at: 8-Nov-2001 17:08
Hi Joel,
perfect. Could you try this one?
method5: [
any [thru "..." t: any #"." u: [(remove/part t: back t u) :t | :t]]
to end
]
parse/all s method5
Joel: <<Hi, all,
Incorporating two from Brett (PRS1 and PRS2) and one from Ladislav
(PANY) and pruning out the also-rans from before, here's a new set
of benchmarks.
I should have pointed out that I owe Anton thanks for the idea that
led to PASS; it was based on FIND, but stayed within the same string
to avoid the quadratic search time.
My rendering of the new versions (so that Brett and Ladislav can
catch any mistakes I made in copying their ideas) are:
PANY:
while [s: find/tail s "..."] [
parse s [any #"." t:]
s: remove/part back s t
]
PRS1:
parse/all s [
any [
".." mark1: any #"." mark2: (remove/part mark1 mark2) :mark1
|
skip
]
]
PRS2:
nondot: complement charset {.}
parse/all s [
any [
some nondot
|
".." mark1: any #"." mark2: (remove/part mark1 mark2) :mark1
|
skip
]
]
The format of these results is similar to the prior benchmarks, so
I won't repeat the format explanations. Here we go!
10 10000 xxxxxxxxx.
pass 0.0069106 17
pany 0.0076094 18.7
binr 0.0132569 32.6
prs2 0.0191155 47.1
prs1 0.0406086 100
10 10000 xxxxx.....
prs1 0.0871603 74.6
prs2 0.0914357 78.3
pany 0.0934973 80
pass 0.1151389 98.6
binr 0.1168064 100
10 10000 x.........
prs1 0.0696221 11.8
prs2 0.0700051 11.9
pany 0.1082873 18.3
binr 0.1837931 31.1
pass 0.5906865 100
10 20000 xxxxxxxxx.
pany 0.0100858 13.3
pass 0.0108703 14.3
binr 0.0318814 41.9
prs2 0.035362 46.5
prs1 0.0760936 100
10 20000 xxxxx.....
prs2 0.2665442 72.3
pany 0.2693659 73.1
prs1 0.2765645 75
binr 0.3451197 93.6
pass 0.3687329 100
10 20000 x.........
prs1 0.2450383 11.4
prs2 0.2724432 12.7
pany 0.3112488 14.5
binr 0.4685498 21.9
pass 2.1415553 100
10 30000 xxxxxxxxx.
pass 0.0140541 12.6
pany 0.0152802 13.7
binr 0.0286012 25.6
prs2 0.0626263 56
prs1 0.1117849 100
10 30000 xxxxx.....
prs1 0.4763552 54.6
pany 0.5014254 57.5
prs2 0.544646 62.4
binr 0.635237 72.8
pass 0.8727375 100
10 30000 x.........
prs1 0.4685633 8.7
prs2 0.4988843 9.3
pany 0.6283518 11.7
binr 0.8068603 15
pass 5.3884561 100
-jn-
--
Then anyone who leaves behind him a written manual, and likewise
anyone who receives it, in the belief that such writing will be
clear and certain, must be exceedingly simple-minded...
-- Plato
FIX^PUNCTUATION^joel^dot^neely^at^fedex^dot^com