moveWindow

fun <S, T, K> List<S>.moveWindow(window: List<T>, multiplication: (baseElement: S, otherElement: T) -> K, addition: (K, K) -> K, shape: MovingWindowShape = MovingWindowShape.FULL): List<K>

Returns a list, over which window was moved/ slided over. This function is an abstract implementation of the moving average, but it can also be used to realize boolean window filters.

Receiver

the list over which the window is moved

Return

the size of the resulting list depends on the shape

Parameters

window

the window is moved or slided over the receiver

multiplication

higher order function for multiplying the elements of the receiver list with elements of the window

addition

higher order function for addition the results to reduce them to the list with elements of type K

shape

the resulting list is as long as the base list if MovingWindowShape.SAME or base.size + other.size, if MovingWindowShape.FULL


fun List<Boolean>.moveWindow(window: List<Boolean>, shape: MovingWindowShape = MovingWindowShape.FULL): List<Boolean>

Moving a window over a Boolean list with boolean window.

Receiver

the list over which the window is moved

Return

an element of the returned list is true, if the multiplication of at least one element of the receiver and window list is true

Parameters

window

the window is moved or slided over the receiver

shape

the resulting list is as long as the base list if MovingWindowShape.SAME or base.size + other.size, if MovingWindowShape.FULL