Skip to content

Instantly share code, notes, and snippets.

@parsonsmatt
Last active June 25, 2017 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parsonsmatt/508d8b72852344da937f1570ae0ff139 to your computer and use it in GitHub Desktop.
Save parsonsmatt/508d8b72852344da937f1570ae0ff139 to your computer and use it in GitHub Desktop.
repeats
-- me
skips :: [a] -> [[a]]
skips xs = zipWith takeEvery [1..length xs] (repeat xs)
takeEvery :: Int -> [a] -> [a]
takeEvery n xs
| n > length xs = []
| otherwise = xs !! (n-1) : takeEvery n (drop n xs)
-- the guy she tells me not to worry about
repeats :: [a] -> [[a]]
repeats xs =
map (map fst . filter snd)
. zipWith zip (map (const xs) xs)
. map cycle
. iterate (False :)
$ [True]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment