moy-fp
Version:
A functional programming library.
18 lines (15 loc) • 325 B
JavaScript
import curry from '../Function/curry'
/**
* Number -> [a] -> [[a]]
*/
const aperture = curry(
(n, array) => {
const limit = array.length - n + 1,
list = [];
for(let index = 0; index < limit; index ++){
list.push(array.slice(index, index + n))
}
return list
}
)
export default aperture