99 Elm Problems/Problem 16/Solutions

Solution 1: Using List.foldr and List.indexedMap

dropEvery n list =
  let
    indexed = List.indexedMap (,) list
    maybeAdd (i, x) xs =
      if (i + 1) % n == 0 then xs else x :: xs        
  in
    List.foldr maybeAdd [] indexed