;Compare a value in an array with neighbours. neighbours is per side
(bind-func greater_than_neighbours
(lambda (buffer:float* offset:i64 num_neighbours:i64)
(let ((n:i64 0)
(peak:i64 1))
(dotimes (n num_neighbours)
(cond ((and (= peak 1) (> (pref buffer offset) (pref buffer (+ offset (+ n 1)))) (> (pref buffer offset) (pref buffer (- offset (+ n 1)))))
(set! peak 1))
(else
(set! peak 0))))
peak)))