As you and bheklilr mention, cycle provides a good way to accomplish this. You can use the tape a bit though:
mapEvery :: Int -> (a -> a) -> [a] -> [a] mapEvery nf = zipWith ($) (drop 1 . cycle . take n $ f : repeat id)
Using zipWith and cycle seems more idiomatic (complex behavior consisting of simpler behavior) than a manual recursive function combining both tasks.
Note: tail here makes this function undefined for n = 0 , so drop 1 is preferred.
There is no library function that I know of for this.
source share