PasteRack.org
Paste # 71948
2016-12-09 00:28:52

Fork as a new paste.

Paste viewed 119 times.


Embed:

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

=>

53

100

809/10