Extracting every 3rd element from a list
Just Evan
10月 02 2024 | 12:30 午前
Hi, how can I extract every 3rd element of a list in order and vice versa, extract everything except every 3rd element, simply skipping it?
Example #1: from the list "A B C D E F G" I need to leave only "C F" (every 3rd element).
Example #2: from the list "A B C D E F G" I need to leave only "A B D E G" (everything except every 3rd element).
Just Evan
10月 02 2024 | 1:09 午前
My version:
I’ll just leave it here, maybe it will be useful to someone)
sousastep
10月 02 2024 | 3:15 午前
idk why the deferlow's needed but it is
Peter Ostry
10月 02 2024 | 5:00 午前
Other versions:
[regexp] should be able to do it in a single object, but I don't know how to write it.
Roman Thilenius
10月 02 2024 | 6:25 午前
your counter approach is good, but you do not even have to iter for that - you can use it with [zl nth].
another version would be iter - group 3 - zl slice - group
TFL
10月 02 2024 | 7:15 午前
Another iter/slice/groupe variation