8 lines
164 B
Racket
8 lines
164 B
Racket
#lang racket
|
|
(define (fold f xs init)
|
|
(if (empty? xs)
|
|
init
|
|
(f (first xs)
|
|
(fold f (rest xs) init))))
|
|
|
|
(fold + '(1 2 3) 0) ; the result is 6
|