mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-03 05:31:54 -07:00
Use 'drop 1' rather than tail, skip equality check.
This commit is contained in:
@@ -199,10 +199,11 @@ promote w = maybe w id $ do
|
|||||||
-- > swap a b . swap a b == id
|
-- > swap a b . swap a b == id
|
||||||
--
|
--
|
||||||
swap :: Eq a => a -> a -> [a] -> [a]
|
swap :: Eq a => a -> a -> [a] -> [a]
|
||||||
swap a b xs = head $ [insertAt bi a (insertAt ai b xs) | a /= b
|
swap a b xs = maybe xs id $ do
|
||||||
,Just ai <- [L.elemIndex a xs], Just bi <- [L.elemIndex b xs]]
|
ai <- L.elemIndex a xs
|
||||||
++ [xs]
|
bi <- L.elemIndex b xs
|
||||||
where insertAt n x ys = as ++ x : tail bs
|
return . insertAt bi a . insertAt ai b $ xs
|
||||||
|
where insertAt n x ys = as ++ x : drop 1 bs
|
||||||
where (as,bs) = splitAt n ys
|
where (as,bs) = splitAt n ys
|
||||||
|
|
||||||
--
|
--
|
||||||
|
Reference in New Issue
Block a user