From 4c3e22df5def04cb0032a76a5088e14f8cea9704 Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Mon, 4 Jun 2007 20:35:35 +0200 Subject: swapUp/Down are also mirrored darcs-hash:20070604183535-a5988-5ab9553321805a39ea9ada8aba0a4c53496eee4d --- StackSet.hs | 11 +++++------ 1 file 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 -- cgit v1.2.3