mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-13 19:15:44 -07:00
shrink 'swap'
This commit is contained in:
13
StackSet.hs
13
StackSet.hs
@@ -202,14 +202,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
|
swap a b xs | a == b = xs -- do nothing
|
||||||
| a == b = xs -- do nothing
|
| Just ai <- L.elemIndex a xs
|
||||||
| Just ai <- L.elemIndex a xs
|
, Just bi <- L.elemIndex b xs = insertAt bi a (insertAt ai b xs)
|
||||||
, Just bi <- L.elemIndex b xs = insertAt bi a (insertAt ai b xs)
|
where insertAt n x ys = as ++ x : tail bs
|
||||||
where
|
where (as,bs) = splitAt n ys
|
||||||
insertAt n x ys = as ++ x : tail bs
|
|
||||||
where (as,bs) = splitAt n ys
|
|
||||||
|
|
||||||
swap _ _ xs = xs -- do nothing
|
swap _ _ xs = xs -- do nothing
|
||||||
|
|
||||||
--
|
--
|
||||||
|
Reference in New Issue
Block a user