How do I do convolution in F#?
问题 I would like convolve a discrete signal with a discrete filter. The signal and filter is sequences of float in F#. The only way I can figure out how to do it is with two nested for loops and a mutable array to store the result, but it does not feel very functional. Here is how I would do it non-functional: conv = double[len(signal) + len(filter) - 1] for i = 1 to len(signal) for j = 1 to len(filter) conv[i + j] = conv[i + j] + signal(i) * filter(len(filter) - j) 回答1: Try this function: let