lua-users home
lua-l archive

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


not (a < b) means that if they are equal, it will return true and lua
needs it to be false if they are equal.
where (a > b) returns false if they are equal.

Thats the only case where they are different.

Example:
a b > !< 
1 1 F  T
1 2 T  T
2 1 F  F

Very interesting interaction that I'm glad I know now :)

Ryan.

On Mon, 26 Jul 2004 12:27:23 -0500, Virgil Smith <virgil@nomadics.com> wrote:
> Quick comment/curiosity...
> 
> does "return (a > b)" work?
> 
> This is different from "return not (a < b)".
> 
> 
> 
> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br
> [mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Michel Machado
> Sent: Monday, July 26, 2004 11:21 AM
> To: lua@bazar2.conectiva.com.br
> Subject: Sort problem
> 
> Dears,
> 
>   The code below (test.lua) fails:
> 
> t = {"a", "b", "a", "a"}
> 
> table.sort(t,
>   function (a, b)
>     assert(a ~= nil, "left var is nil!")
>     assert(b ~= nil, "right var is nil!")
>     return not (a < b) -- I want an inverted sort!
>   end)
> 
> for i, v in ipairs(t) do
>   print(i, v)
> end
> 
>   The error:
> 
> [michel@michel michel]$ lua test.lua
> lua: test.lua:5: left var is nil!
> stack traceback:
>         [C]: in function `assert'
>         test.lua:5: in function <test.lua:4>
>         [C]: in function `sort'
>         test.lua:3: in main chunk
>         [C]: ?
> 
>   Did I make some mistake?
> 
> [ ]'s
> Michel Machado
> 
>