lua-users home
lua-l archive

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


On 17 July 2015 at 13:06, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>
> APL has an operator "scan" over arrays so that
>
>    fct / x
>
> returns the value of a function that can be coded in Lua as
>
> function scan(fct,x)
>    result = unit(fct)
>    for _,v in ipairs(x) do result = fct(result,v) end
>    return result
> end
>

https://en.wikipedia.org/wiki/Fold_(higher-order_function)

-- 
-alex
http://unendli.ch/