summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-06-04 23:15:31 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-06-04 23:15:31 +0200
commit613d1547f5b3cb03422550d8798c8cb4985e2313 (patch)
treebda6e0aeb05844f4b06d8d8448da24f14054dbb6
parentf6423d270467d640c4b38c8803fb67fec8728180 (diff)
downloadmetatile-613d1547f5b3cb03422550d8798c8cb4985e2313.tar
metatile-613d1547f5b3cb03422550d8798c8cb4985e2313.zip
-Wall police
darcs-hash:20070604211531-a5988-b12f8e4adbb881ac760733d2e022656329fc8f30
-rw-r--r--StackSet.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 05a5ca3..e6af069 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -273,19 +273,22 @@ index = with [] integrate
focusUp, focusDown, swapUp, swapDown :: StackSet i a s -> StackSet i a s
focusUp = modify Empty focusUp'
-focusUp' (Node t (l:ls) rs) = Node l ls (t:rs)
-focusUp' (Node t [] rs) = Node x xs [] where (x:xs) = reverse (t:rs)
-
focusDown = modify Empty (reverseStack . focusUp' . reverseStack)
swapUp = modify Empty swapUp'
+swapDown = modify Empty (reverseStack . swapUp' . reverseStack)
+
+focusUp', swapUp' :: Stack a -> Stack a
+
+focusUp' (Node t (l:ls) rs) = Node l ls (t:rs)
+focusUp' (Node t [] rs) = Node x xs [] where (x:xs) = reverse (t:rs)
+
swapUp' (Node t (l:ls) rs) = Node t ls (l:rs)
swapUp' (Node t [] rs) = Node t (reverse rs) []
-swapDown = modify Empty (reverseStack . swapUp' . reverseStack)
-
-- reverse a stack: up becomes down and down becomes up.
+reverseStack :: Stack a -> Stack a
reverseStack (Node t ls rs) = Node t rs ls
reverseStack x = x