diff options
author | Wirt Wolff <wirtwolff@gmail.com> | 2010-01-24 00:19:12 +0100 |
---|---|---|
committer | Wirt Wolff <wirtwolff@gmail.com> | 2010-01-24 00:19:12 +0100 |
commit | fe0867cad9031b954185296fc2ff0825efc95bda (patch) | |
tree | 1f779376e6104c004df076d3b258ed2f0c1b66b9 /XMonad/Actions | |
parent | c37ed1835d53cfb73a7b36019fe8d4fb315cd502 (diff) | |
download | XMonadContrib-fe0867cad9031b954185296fc2ff0825efc95bda.tar.gz XMonadContrib-fe0867cad9031b954185296fc2ff0825efc95bda.tar.xz XMonadContrib-fe0867cad9031b954185296fc2ff0825efc95bda.zip |
A.CycleWindows replace partial rotUp and rotDown with safer versions
Ignore-this: 6b4e40c15b66fc53096910e85e736c23
Rather than throw exceptions, handle null and singleton lists, i.e.
f [] gives [] and f [x] gives [x].
darcs-hash:20100123231912-18562-6986c6acb711331ab135e62e1a41fbe8aabf5f13.gz
Diffstat (limited to 'XMonad/Actions')
-rw-r--r-- | XMonad/Actions/CycleWindows.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/XMonad/Actions/CycleWindows.hs b/XMonad/Actions/CycleWindows.hs index a1d2fee..97e667b 100644 --- a/XMonad/Actions/CycleWindows.hs +++ b/XMonad/Actions/CycleWindows.hs @@ -226,8 +226,10 @@ rotUnfocused' f (W.Stack t ls rs) = W.Stack t (reverse revls') rs' -- otherwis (revls',rs') = splitAt (length ls) (f $ master:revls ++ rs) -- $generic --- Generic list rotations +-- Generic list rotations such that @rotUp [1..4]@ is equivalent to +-- @[2,3,4,1]@ and @rotDown [1..4]@ to @[4,1,2,3]@. They both are +-- @id@ for null or singleton lists. rotUp :: [a] -> [a] -rotUp l = tail l ++ [head l] +rotUp l = drop 1 l ++ take 1 l rotDown :: [a] -> [a] -rotDown l = last l : init l +rotDown = reverse . rotUp . reverse |