Skip to content

Studio 6

Studio Worksheets

  1. Studio 6 Worksheet
  2. Studio 6 In-class Worksheet

accumulate_right

Implement the accumulate_right function, which is similar to accumulate except that it processes the list from right to left.

function accumulate_right(func, initial, lst) {
    // YOUR SOLUTION HERE
}

// Examples
accumulate_right((x, y) => x + y, 0, list(1, 2, 3, 4, 5)); // 15
accumulate_right((x, y) => x / y, 1, list(1, 2, 3)); // 0.16666666666666666