[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Progressively worse performance from a table
- From: scott <scott+lua@...>
- Date: Sat, 10 Jan 2004 17:41:59 -0500
On Sat, Jan 10, 2004 at 07:28:00PM -0200, Leandro Candido wrote:
> Hello Edgar/scott,
>
> I tested the 2 codes (the one from scott and the one from Edgar), and
> they aren't the same. The code from Edgar doesn't allow to add duplicated
> words (lines, in code examples).
>
> before
>
> print ("-mark- beginning delete")
>
> in the 2 codes, add:
>
> totalItemsInTable = 0;
> table.foreach(words,function() totalItemsInTable = totalItemsInTable + 1
> end);
> print("Number of items in table words:",totalItemsInTable);
>
> The result will be different for scott's and for Edgar's code.
> This is because in the Edgar's code, if the item is already in the table, it
> isn't added twice. This is a good thing, but the idea of Edgar was to mimics
> the behavior from scott's code, and in this case, it isn't equal.
>
> The God's Peace,
>
>
> Leandro.
>
Good call! The original code was intended to store lists of words, which
of course needs to be able to handle duplicates. My example data
('/usr/share/dict/') and even my unit tests have no duplicates so I wasn't
even considering this situation.
For anyone interesed in what I was doing, take a look at
http://www.pragprog.com/pragdave/Practices/Kata/KataTwentyOne.rdoc I'm
using the programming exercises suggested by Dave Thomas as a way to
experiment with Lua.
scott
--
------------------------------------------------------------------------
scott jacobs scott+lua@escherichia.net
------------------------------------------------------------------------