summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-06-04 20:35:35 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-06-04 20:35:35 +0200
commit4c3e22df5def04cb0032a76a5088e14f8cea9704 (patch)
tree3081d8a9b354e67da4d6a956b247f3ee0a966a9e
parent8252c263305bc52db9c71cde73faac8cecc4fb93 (diff)
downloadmetatile-4c3e22df5def04cb0032a76a5088e14f8cea9704.tar
metatile-4c3e22df5def04cb0032a76a5088e14f8cea9704.zip
swapUp/Down are also mirrored
darcs-hash:20070604183535-a5988-5ab9553321805a39ea9ada8aba0a4c53496eee4d
-rw-r--r--StackSet.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 2b6ed68..9ce1df9 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -278,13 +278,12 @@ focusUp' (Node t [] rs) = Node x xs [] where (x:xs) = reverse (t:rs)
focusDown = modify Empty (reverseStack . focusUp' . reverseStack)
-swapUp = modify Empty $ \c -> case c of
- Node t (l:ls) rs -> Node t ls (l:rs)
- Node t [] rs -> Node t (reverse rs) []
+swapUp = modify Empty swapUp'
-swapDown = modify Empty $ \c -> case c of
- Node t ls (r:rs) -> Node t (r:ls) rs
- Node t ls [] -> Node t [] (reverse ls)
+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 (Node t ls rs) = Node t rs ls