RosettaCodeData/Task/Cumulative-standard-deviation/Racket/cumulative-standard-deviation.rkt

8 lines
213 B
Racket
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
#lang racket
(require math)
(define running-stddev
(let ([ns '()])
(λ(n) (set! ns (cons n ns)) (stddev ns))))
;; run it on each number, return the last result
(last (map running-stddev '(2 4 4 4 5 5 7 9)))