1
0
mirror of https://github.com/xmonad/xmonad.git synced 2025-08-13 02:55:46 -07:00

shrink 'swap'

This commit is contained in:
Don Stewart
2007-04-30 02:48:13 +00:00
parent 9fafa995c7
commit a07f0778ad

@@ -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
--