From 9dbe49802ab820439e4072b8c060775523836e3e Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Mon, 4 Jun 2007 20:31:43 +0200 Subject: focusUp/Down are the same, in reversed order darcs-hash:20070604183143-a5988-9b9325a10eee13bb6bd96d20ca3b15c12c368883 --- StackSet.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/StackSet.hs b/StackSet.hs index 8f8c4e3..d1fe054 100644 --- a/StackSet.hs +++ b/StackSet.hs @@ -271,13 +271,12 @@ index = with [] integrate -- the current stack. -- focusUp, focusDown, swapUp, swapDown :: StackSet i a s -> StackSet i a s -focusUp = modify Empty $ \c -> case c of - Node t (l:ls) rs -> Node l ls (t:rs) - Node t [] rs -> Node x xs [] where (x:xs) = reverse (t:rs) +focusUp = modify Empty focusUp' -focusDown = modify Empty $ \c -> case c of - Node t ls (r:rs) -> Node r (t:ls) rs - Node t ls [] -> Node x [] xs where (x:xs) = reverse (t:ls) +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 $ \c -> case c of Node _ [] [] -> c @@ -289,6 +288,10 @@ swapDown = modify Empty $ \c -> case c of Node t ls (r:rs) -> Node t (r:ls) rs Node t ls [] -> Node t [] (reverse ls) +-- reverse a stack: up becomes down and down becomes up. +reverseStack (Node t ls rs) = Node t rs ls +reverseStack x = x + -- -- | /O(1) on current window, O(n) in general/. Focus the window 'w', -- and set its workspace as current. -- cgit v1.2.3