PasteRack.org
Paste # 26806
2016-12-09 00:14:55

Fork as a new paste.

Paste viewed 56 times.


Embed:

  1. #lang racket
  2. (define (min list)
  3.     (cond ((null? (cdr list)) (car list))
  4.           ((< (car list) (min (cdr list))) (car list))
  5.           (else (min (cdr list)))) )
  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