lua-users home
lua-l archive

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


On Wed, May 13, 2009 at 9:28 AM, steve donovan wrote:
> On Wed, May 13, 2009 at 3:16 PM, David Manura wrote:
>> I mean that the List
>> operation t:map() does not modify t but rather returns a new object.
>> This differs from t:reverse(), which modifies t in-place and returns
>> itself.

I don't really like the complicating DWIM stuff in List:map (i.e.
is_type(arg1,List)):

  function List:map (fun,arg1,...)
    local res
    if is_type(arg1,List) then
        res = map2(fun,self,arg1,...)
    else
        res = imap(fun,self,arg1,...)
    end
    return setmetatable(res,List)
  end

e.g. what if someone really wanted to pass a list as arg1 and have it
operated with imap?