Skip to content

Instantly share code, notes, and snippets.

@okkero
Created July 5, 2017 14:51
Show Gist options
  • Save okkero/d31f621a10d31166c5398f2b64de5d7a to your computer and use it in GitHub Desktop.
Save okkero/d31f621a10d31166c5398f2b64de5d7a to your computer and use it in GitHub Desktop.
import Data.List
onOdds :: ([a] -> [a]) -> [a] -> [a]
onOdds f xs =
let
(odds, evens) = partition (odd . fst) $ zip [0..] xs
in
concat $
zipWith
(\a b -> [a, b])
(snd <$> evens)
(f $ snd <$> odds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment