Mercurial > hg > ishara
view general/funutils/@function_handle/foldr.m @ 38:9d24b616bb06
Added function algebra.
author | samer |
---|---|
date | Tue, 29 Jan 2013 15:59:01 +0000 |
parents | 03694e5c8365 |
children |
line wrap: on
line source
function X=foldr(fn,e,args) % foldr - Fold from the right combinator % % foldr :: (Y,X->X), Y, cells(Y) -> Y. % % This function applies an associative operator to a list of arguments, % starting from the right, eg % elements, eg foldr(@plus,0,{1,2,3,4}) = (1+(2+(3+(4+0)))). X=e; for i=length(args):-1:1, X=fn(args{i},X); end