diff options
-rw-r--r-- | StackSet.hs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/StackSet.hs b/StackSet.hs index 73c3bfb..a480792 100644 --- a/StackSet.hs +++ b/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 -- |