Created
October 14, 2009 03:01
-
-
Save jutememo/209759 to your computer and use it in GitHub Desktop.
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
module Mainbak01 where | |
import Stack | |
comb :: (Stack a -> (a, Stack a)) | |
-> (a -> (Stack a -> (a, Stack a))) | |
-> Stack a -> (a, Stack a) | |
comb m n = \stack0 -> | |
let (x1, stack1) = m stack0 | |
(x2, stack2) = n x1 stack1 | |
in (x2, stack2) | |
ret :: a -> (Stack a -> (a, Stack a)) | |
ret x = \stack -> (x, stack) | |
comb_ :: (Stack a -> (a, Stack a)) | |
-> (Stack a -> (a, Stack a)) | |
-> Stack a -> (a, Stack a) | |
comb_ m n = m `comb` (\_ -> n) | |
main = do | |
print $ pop `comb` (\x1 -> pop) $ s | |
print $ pop `comb` (\x1 -> pop `comb` \x2 -> ret(x1 + x2)) $ s | |
print $ pop `comb` (\x1 -> | |
pop `comb` \x2 -> | |
pop `comb` \x3 -> | |
ret $ (x1 + x3) * x2) $ s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment