lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thierry <th.douez@sunnyrevtalk.com> writes:

>>> Le 5 oct. 2010 à 14:27, Michal Kolodziejczyk a écrit :
>> It is part of Lua Programming Gems:
>> http://www.lua.org/gems/
>
> Thanks.
> By the way, I've just received the Programming in Lua 2nd edition.
> Very good book.
>
> Ok, my next neuronal-challenge as a Lua-learner :)
>
> I have this simple script :
>
> function m( x0, radius) -- radius : ~ 2 to 7
>   local t =  {}
>   local N = 0
>   for x = x0-radius, x0+radius do
>       t[N] = get_val( x )
>       N = N + 1
>     end
>   table.sort( t )
>   .....
> end

That is rather awful, you know.  Lua arrays start indexing at 1.  So the
sort routine will not touch the data at index 0.

-- 
David Kastrup