source: node_modules/ramda-adjunct/es/skipTake.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 751 bytes
RevLine 
[d24f17c]1import { curry, addIndex, filter, pipe, modulo, identical, nthArg, __ } from 'ramda';
2
3/**
4 * When given a number n and an array, returns an array containing every nth element.
5 *
6 * @func skipTake
7 * @memberOf RA
8 * @category List
9 * @since {@link https://char0n.github.io/ramda-adjunct/2.26.0|v2.26.0}
10 * @sig Number -> [a] -> [a]
11 * @param {number} the nth element to extract
12 * @param {Array} value the input array
13 * @return {Array} An array containing every nth element
14 * @example
15 *
16 * RA.skipTake(2, [1,2,3,4]) //=> [1, 3]
17 * RA.skipTake(3, R.range(0, 20)); //=> [0, 3, 6, 9, 12, 15, 18]
18 */
19
20var skipTake = curry(function (n, list) {
21 return addIndex(filter)(pipe(nthArg(1), modulo(__, n), identical(0)))(list);
22});
23export default skipTake;
Note: See TracBrowser for help on using the repository browser.