fold_right


fold_right(fn, init, @rest xs, ...)
      

Return init if the list arguments xs, ... are empty. If they are not empty, recur with the tail of each list, then apply the function fn to their heads and the result returned by the recursion.

The list arguments should all have the same length. Fn should accept one more argument than the number of list arguments and return a single value. It should not mutate the lists.

Examples:


fold_right(^(x, init) init + x * x, 0, [1, 2, 3, 4, 5])
// 55

fold_right(pair, [], [1,2,3,4])
// [1, 2, 3, 4]

fold_right(`-`, 0, [1, 2, 3, 4])
// -2
      

Also see:

fold
fold_left
accumulate
map


Core Module Index | Contents