mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-13 02:55:46 -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 :: Eq a => a -> a -> [a] -> [a]
|
||||
swap a b xs
|
||||
| a == b = xs -- do nothing
|
||||
| Just ai <- L.elemIndex a xs
|
||||
, Just bi <- L.elemIndex b xs = insertAt bi a (insertAt ai b xs)
|
||||
where
|
||||
insertAt n x ys = as ++ x : tail bs
|
||||
where (as,bs) = splitAt n ys
|
||||
|
||||
swap a b xs | a == b = xs -- do nothing
|
||||
| Just ai <- L.elemIndex a xs
|
||||
, Just bi <- L.elemIndex b xs = insertAt bi a (insertAt ai b xs)
|
||||
where insertAt n x ys = as ++ x : tail bs
|
||||
where (as,bs) = splitAt n ys
|
||||
swap _ _ xs = xs -- do nothing
|
||||
|
||||
--
|
||||
|
Reference in New Issue
Block a user