lua-users home
lua-l archive

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


On Thu, 17 Dec 2009, steve donovan wrote:
>
> And then consider the useful map2(fun,t1,t2) where fun takes two
> arguments, the corresponding values from t1 and t2.

Traditional functional libraries don't have a map2() function since
it can be trivially defined as something like:

	function map2(f,xs,ys)
		return map(f,zip(xs,ys))
	end

In functional languages there's a tension between curried and uncurried
functions here, since map() and zip() are commonly defined in curried
style but f() must be uncurried, taking its arguments in a tuple
constructed by zip().

I suppose in Lua this translates to passing arguments in the usual way or
in a table. In this case the rough Lua equivalents of curry() and
uncurry() are unpack() and select().

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.