Created
May 27, 2017 20:23
-
-
Save danlaudk/acc55550b36c0d6de517e9e10cf786d2 to your computer and use it in GitHub Desktop.
forth at rc wk1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Control.Monad.State.Strict | |
import Control.Applicative (liftA3) | |
import Control.Monad (replicateM) | |
import Control.Monad.Trans.State | |
type Stack = List[Int] | |
pop :: State Stack Int | |
pop = state $ \x -> | |
case x of | |
head::tail -> (head, tail) | |
_ -> (0, []) | |
swap = do | |
a <- pop | |
b <- pop | |
_ <- push b | |
_ <- push a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment