If you start with a sequence:-
user=> (def s (range 1 20))
#'user/s
user=> s
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)
You can break this into sections where all except the last one have n elements and the final one has up to n elements depending on how many are left: this is the function partition-all:-
user=> (partition-all 4 s)
((1 2 3 4) (5 6 7 8) (9 10 11 12) (13 14 15 16) (17 18 19))
user=> (partition-all 5 s)
((1 2 3 4 5) (6 7 8 9 10) (11 12 13 14 15) (16 17 18 19))
user=> (partition-all 6 s)
((1 2 3 4 5 6) (7 8 9 10 11 12) (13 14 15 16 17 18) (19))
This is different from function partition, which would silently omit the final elements if there were not enough to make another batch of n.
So now I can take only n-1 elements from each batch, there's a function drop-last which does this:
user=> (map drop-last (partition-all 6 s))
((1 2 3 4 5) (7 8 9 10 11) (13 14 15 16 17) (19))
So the final element from each batch of 6 goes. Then flatten the batches to make a single sequence:-
user=> (flatten (map drop-last (partition-all 6 s)))
(1 2 3 4 5 7 8 9 10 11 13 14 15 16 17 19)
There we are, each 6th element dropped. Far more functional than the solution that works through the list.
Therefore the function to drop every nth item from a sequence looks like this:
(defn drop-nth [n s]
(flatten (map drop-last (partition-all n s))))
Isn't that honey?