PasteRack.org
Paste # 72198
2016-12-09 00:26:17

Fork as a new paste.

Paste viewed 48 times.


Embed:

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

=>

53

100

809/10