I’m implementing a simple lowpass filter.
open Belt
let lowpass_filter = (data, window_size) => {
let len = data->Array.length
let result = Array.make(len, 0.0)
for i in 0 to len - 1 {
let start = max(0, i - window_size / 2)
let end = min(len, i + window_size / 2 + 1)
let l = end - start
let slice = data->Array.slice(~offset=start, ~len=l)
let sum = slice->Array.reduce(0.0, (s, v) => s +. v)
let value = sum /. l->Int.toFloat
Js.Console.log(">>>><<<<")
result[i] = value
}
result
}
But this result in a type error which claims the result[i] = value
is an expression of type bool.
Is this a bug?