Created
August 31, 2024 19:58
-
-
Save ncalm/48b96ac45685a7897fdf0a7336b2e96b to your computer and use it in GitHub Desktop.
LAMBDA for generating an arbitrary skipped list of integers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Return every 'x' integers no larger than n, optionally skipping the first 'skip' | |
integers in such a sequence | |
e.g. | |
EveryXtoN(10, 2) = {1; 3; 5; 7; 9} | |
EveryXtoN(10, 2, 1) = {3; 5; 7; 9} | |
EveryXtoN(10, 2, 2) = {5; 7; 9} | |
EveryXtoN(10, 3) = {1; 4; 7; 10} | |
EveryXtoN(10, 3, 1) = {4; 7; 10} | |
EveryXtoN(10, 3, 2) = {7; 10} | |
*/ | |
EveryXtoN = LAMBDA(n, x, [skip], | |
SEQUENCE(CEILING.MATH((n - (x*skip)) / x), , (x*skip)+1, x) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment