samer@13: function X=foldr(fn,e,args) samer@13: % foldr - Fold from the right combinator samer@13: % samer@13: % foldr :: (Y,X->X), Y, cells(Y) -> Y. samer@13: % samer@13: % This function applies an associative operator to a list of arguments, samer@13: % starting from the right, eg samer@13: % elements, eg foldr(@plus,0,{1,2,3,4}) = (1+(2+(3+(4+0)))). samer@13: X=e; for i=length(args):-1:1, X=fn(args{i},X); end