-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
skipping #18
Comments
right now i am using |
I think let skip n gen =
let i = ref n in
let rec next() =
match gen() with
| None -> None
| Some x when !i = 1 ->
i := n; Some x
| Some _ ->
decr i; next()
in next |
i would agree that the simple one is probably enough in >90% of the cases. the more general one just occurred to me by imagining a scenario like "i need successive pairs which occur every 7 elements" or something like that. however, then one could probably just use |
about naming: |
|
that's very clear i find. one could argue that |
i have not found a way to take only every nth element -- is this possible? have i missed it? more generally, one could think of a list of 'step lengths' or 'skip lengths' to apply cyclically as one moves over the generator, i.e.
[0;2;1]
means 'take next element, then skip two and take one, then skip one and take one, then take the next element, etc.,..'The text was updated successfully, but these errors were encountered: