From: "Joel Neely"
<snip amount=large />
> Variant #2
> ----------
>
> 8<--------------------(begin tallyb.r)--------------------
> #!/export/home/jneely/bin/rebol -sq
>
> REBOL []
>
> text:  read %alice.txt
> tally: []
> alpha: charset [#"a" - #"z"]
> word:  ""
>
> parse/all lowercase text [
>     any [
>         copy word some alpha (
>             either here: select tally word [
>                 change here here/1 + 1
>             ][
>                 repend tally [word copy [1]]
>             ]
>         )
>     |
>         skip
>     ]
> ]
>
> foreach [word count] sort/skip tally 2 [
>     print [first count tab word]
> ]
>
> quit
>
> 8<---------------------(end tallyb.r)---------------------
<snip>
> Despite the extra level of nesting, the speed improves again:
>
>     (/export/home/jneely/try)# time tallyb.r > /dev/null
>
>     real    0m5.53s
>     user    0m5.45s
>     sys     0m0.08s
<snip amount=(to end)>

Hi, Joel, et al,

Using this version of the algorithm and using precise timing on the parsing
loop only on a Win98 deCeleron 500 and an apparently slightly different
version of alice, I obtained 0:00:11.31.  Making a hash out of tally by
changing:
    tally: []
to
    tally: to-hash []
I obtained a time of 0:00:00.5.  Unfortunately, I don't know enough Perl to
run Joel's equivalent code with the Alice file for direct comparison.

Having pointed out the significant improvement that hash provides should not
distract from one of Joel's original points that if RT's time/resources
is/are limited, it would probably be better to spend time optimizing core
functionality and making the environment more readily extensible with ad-hoc
native functionality, when needed. In other correspondence, Carl S. has
apparently indicated that he thought a percent type would be useful in gui
construction but that the ROI was not enough to spend the time to work out
the details.  As always, with a little bit of cash, I suspect RT would
happily work out the details!
:-)

I wish I had 2% of $1 to give away!!!  At least my ideas are *free* (0% of
$1) and easily worth every penny of it!
;-)
--Scott Jones

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to