Skip to content

Instantly share code, notes, and snippets.

@dminuoso
Created December 6, 2017 14:17
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 dminuoso/e8eeccee5177708d0a1de82ece4cd5c1 to your computer and use it in GitHub Desktop.
Save dminuoso/e8eeccee5177708d0a1de82ece4cd5c1 to your computer and use it in GitHub Desktop.
combine1 :: (a -> a) -> State [a] ()
combine1 op = do
a <- pop
push $ op a
combine2 :: (a -> a -> a) -> State [a] ()
combine2 op = do
a <- pop
b <- pop
push op a b
combine3 :: (a -> a -> a -> a) -> State [a] ()
combine3 op = do
a <- pop
b <- pop
c <- pop
push $ op a b c
combine4 :: (a -> a -> a -> a -> a) -> State [a] ()
combine4 op = do
a <- pop
b <- pop
c <- pop
d <- pop
push $ op a b c d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment