summaryrefslogtreecommitdiff
path: root/pole.hs
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2014-08-09 10:58:03 +0800
committerJoe Zhao <ztuowen@gmail.com>2014-08-09 10:58:03 +0800
commit5bdaa1e4ffe40add10f000ee993e6b500c419a37 (patch)
tree46a624488ece8d37fa3580422234ed2b4acc6728 /pole.hs
parent01aa73b269f7ad780233be338affdf3c9288b1ed (diff)
downloadhaskbox-old-5bdaa1e4ffe40add10f000ee993e6b500c419a37.tar.gz
haskbox-old-5bdaa1e4ffe40add10f000ee993e6b500c419a37.tar.bz2
haskbox-old-5bdaa1e4ffe40add10f000ee993e6b500c419a37.zip
add files from home for previous chapters and sandboxes
Diffstat (limited to 'pole.hs')
-rw-r--r--pole.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/pole.hs b/pole.hs
new file mode 100644
index 0000000..4ec54d4
--- /dev/null
+++ b/pole.hs
@@ -0,0 +1,27 @@
+type Birds = Int
+type Pole = (Birds, Birds)
+
+landLeft :: Birds -> Pole -> Maybe Pole
+landLeft n (left, right)
+ | abs((left+n) - right) < 4 = Just (left + n, right)
+ | otherwise = Nothing
+
+landRight :: Birds -> Pole -> Maybe Pole
+landRight n (left, right)
+ | abs((right+n) - left) < 4 = Just (left, right + n)
+ | otherwise = Nothing
+
+foo = do
+ x <- Just 3
+ y <- Just "!"
+ Just (show x ++ y)
+
+routine = do
+ start <- return (0,0)
+ first <- landLeft 2 start
+ second <- landRight 2 first
+ landLeft 1 second
+
+wopwop = do
+ (x:xs) <- Just ""
+ return x