Product SiteDocumentation Site

4.3.2. Example Usage

(define mapper
  (lambda (pair)
    (map-words (string-tokenize (car pair)))))

(define map-words
  (lambda (words)
    (if (null? words) '()
        (cons (list (car words) 1)
              (map-words (cdr words))))))
(define reducer
  (lambda (next-value accumulator)
    (+ next-value accumulator)))

;; or equivalently:
(define reducer +)