aboutsummaryrefslogtreecommitdiffstats
path: root/StackSet.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-05-08 17:09:43 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-05-08 17:09:43 +0200
commit22db9163bf3b003162ccdf3272a27b77f89ad7a0 (patch)
tree30d0ebfbd9eb9a582670fe032fc9d65097b8485c /StackSet.hs
parent0b301c4534b5f28084de89302c76e85bc5627061 (diff)
downloadxmonad-22db9163bf3b003162ccdf3272a27b77f89ad7a0.tar.gz
xmonad-22db9163bf3b003162ccdf3272a27b77f89ad7a0.tar.xz
xmonad-22db9163bf3b003162ccdf3272a27b77f89ad7a0.zip
Use 'drop 1' rather than tail, skip equality check.
darcs-hash:20070508150943-a5988-84c0ebc06bc745ecdacae2ced6863b63a9585756.gz
Diffstat (limited to 'StackSet.hs')
-rw-r--r--StackSet.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 74d63eb..3f615bf 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -199,10 +199,11 @@ promote w = maybe w id $ do
-- > swap a b . swap a b == id
--
swap :: Eq a => a -> a -> [a] -> [a]
-swap a b xs = head $ [insertAt bi a (insertAt ai b xs) | a /= b
- ,Just ai <- [L.elemIndex a xs], Just bi <- [L.elemIndex b xs]]
- ++ [xs]
- where insertAt n x ys = as ++ x : tail bs
+swap a b xs = maybe xs id $ do
+ ai <- L.elemIndex a xs
+ bi <- L.elemIndex b xs
+ return . insertAt bi a . insertAt ai b $ xs
+ where insertAt n x ys = as ++ x : drop 1 bs
where (as,bs) = splitAt n ys
--