lua-users home
lua-l archive

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


In message <dd7236e0-96e6-b437-6515-ab16979289b7@disroot.org>
          dyngeccetor8 <dyngeccetor8@disroot.org> wrote:

> Why not implement tuples via lists?
>
>  tuple =
>    function(...)
>      local result = {type = 'tuple'}
>
>      local process
>      process =
>        function(list)
>          for i, el in ipairs(list) do
>            if (type(el) == 'table') and (el.type == 'tuple') then
>              process(el)
>            else
>              table.insert(result, el)
>            end
>          end
>        end
>
>      process({...})
>
>      return result
>    end
>
>  is_equal =
>    function(t_a, t_b)
>      if (#t_a == #t_b) then
>        for i = 1, #t_a do
>          if (t_a[i] ~= t_b[i]) then
>            return false
>          end
>        end
>        return true
>      else
>        return false
>      end
>    end

I was looking for something that worked with ==.  But thanks
anyway.
-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/