Lecture overview -- Keyboard shortcut: 'u'  Previous page: The reduction functions -- Keyboard shortcut: 'p'  Next page: Zipping -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Recursion and Higher-order Functions - slide 29 : 35

Accumulation

It is not satisfactory that we cannot reduce the empty list

We remedy the problem by passing an extra parameter to the reduction functions

We call this variant of the reduction functions for accumulation

reduction.scm
The function accumulate-right.
Expression

Value

(accumulate-right - 0 '())
0
(accumulate-right - 0 '(1 2 3 4 5))
3
(accumulate-right append '()
  (list (list 1 2 3) (list 'a 'b 'c)))
(1 2 3 a b c)