slide method
returns a list of pairs of values slided by 1. example
[0,1,2,3,4,5,...].slide() // => [(0,1),(1,2),(2,3),(3,4),(4,5),...]
Implementation
Iterable<$<T, T>> slide() =>
fold<$<Iterable<$<T, T>>, T?>>($(Iterable<$<T, T>>.empty(), null),
(acc, element) {
if (acc.$1 == null) {
return $(acc.$0, element);
} else {
return $([...acc.$0, $(acc.$1!, element)], element);
}
}).$0;