PasteRack.org
Paste # 13573
2016-12-09 00:20:25

Fork as a new paste.

Paste viewed 73 times.


Embed:

  1. #lang racket
  2. (define (min lst)
  3.     (cond ((null? (cdr lst)) (car lst))
  4.           ((< (car lst) (min (cdr lst))) (car lst))
  5.           (else (min (cdr lst)))) )
  6. (define (max list)
  7.   (if (null? list)
  8.       #f
  9.       (foldl (lambda (e r) (if (> e r) e r))
  10.              (car list)
  11.              (cdr list))))
  12. (define (avg list)
  13.   (/ (apply + list) (length list)))
  14.  
  15. (min '(100 87 67 53 85 98 92 79 60 88))
  16.  
  17. (max '(100 87 67 53 85 98 92 79 60 88))
  18.  
  19. (avg '(100 87 67 53 85 98 92 79 60 88))
  20.  

=>

min: contract violation

  expected: real?

  given: '(87 67 53 85 98 92 79 60 88)

100

809/10