aboutsummaryrefslogtreecommitdiff
path: root/algebraic-structures.reducible.scm
blob: 49de2e5efe67abd1f91153c9d68a65e02ba5463c (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(functor ((algebraic-structures reducible) (R (reduce)))
    (reduce
     maximum
     minimum)
  (import scheme
          (only R reduce))

  (define (minimum xs less?)
    (reduce (lambda (e acc)
              (if (less? e acc)
                  e
                  acc))
            xs))

  (define (maximum xs less?)
    (reduce (lambda (e acc)
              (if (less? e acc)
                  acc
                  e))
            xs)))