Skip to content

Instantly share code, notes, and snippets.

@dripolles
Created April 14, 2014 13:16
Show Gist options
  • Save dripolles/10646888 to your computer and use it in GitHub Desktop.
Save dripolles/10646888 to your computer and use it in GitHub Desktop.
1HaskellADay 2014/04/14
-- http://lpaste.net/revision/6908970897281908736
import Control.Category ((>>>))
stagedComputation :: [a->a] -> a -> [a]
stagedComputation fs x = tail $ scanl (flip id) x fs
stagedComputation' :: [a->a] -> a -> [a]
stagedComputation' = flip $ scanl (flip id) >>> (tail .)
main = do
print $ stagedComputation [(+1), (*2), subtract 3] 4
print $ stagedComputation' [(+1), (*2), subtract 3] 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment