Skip to content

Instantly share code, notes, and snippets.

@Xetera
Created May 31, 2019 04:52
Show Gist options
  • Save Xetera/8e6bc502d6760db7dd0deaf5b7120c45 to your computer and use it in GitHub Desktop.
Save Xetera/8e6bc502d6760db7dd0deaf5b7120c45 to your computer and use it in GitHub Desktop.
A simple function for generating an infinite list of alternating patterns
makePattern :: [(a -> a)] -> a -> [a]
makePattern funcs seed = scanl (\a f -> f a) seed (cycle funcs)
-- makePattern [(*3), (+1)] 1
-- [1,3,4,12,13,39]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment