Lecture overview -- Keyboard shortcut: 'u'  Previous page: The reduction functions -- Keyboard shortcut: 'p'  Next page: Zipping -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 4 - Page 17 : 34
Functional Programming in Scheme
Higher-order Functions

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

y:/Kurt/Files/courses/prog3/prog3-03/sources/notes/includes/reduction.scmThe function accumulate-right.

The recursive pattern is similar to the pattern of reduce-right.



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

Examples of right accumulations. The first row illustrates that we can accumulate the empty list. The second and third rows are similar to the second and third rows in Table 15.1.

In relation to web programming we most often append accumulate lists and strings

accumulate-right is part of the general LAML library

Due to their deficiencies, the reduction functions are not used in LAML