10 lines
225 B
Common Lisp
10 lines
225 B
Common Lisp
(lib 'tree) ;; queues operations
|
|
|
|
|
|
(define (make-sma p)
|
|
(define Q (queue (gensym)))
|
|
(lambda (item)
|
|
(q-push Q item)
|
|
(when (> (queue-length Q) p) (q-pop Q))
|
|
(// (for/sum ((x (queue->list Q))) x) (queue-length Q))))
|
|
|