2 implementations of vmedian:
#1
/digego/extempore/tree/v0.8.9/libs/core/math.xtm ·
#2
/digego/extempore/tree/v0.8.9/libs/core/math.xtm
(bind-func vmedian
(lambda (buf:double* len:i64)
(let ((h (vsort buf len))
(idx (dtoi64 (ceil (/ (i64tod len) 2.0)))))
(if (evenp len)
(/ (+ (pref h idx) (pref h (- idx 1))) 2.0)
(pref h idx)))))