diff options
author | Don Stewart <dons@cse.unsw.edu.au> | 2007-04-30 04:48:13 +0200 |
---|---|---|
committer | Don Stewart <dons@cse.unsw.edu.au> | 2007-04-30 04:48:13 +0200 |
commit | 50acc330c987a406715025d6dcead4b304223bb3 (patch) | |
tree | 1d26f00066a3afa99df59ec78af0d9406ccbaec3 | |
parent | 24965e48e5df8e0a83dfceb45fdae5bf04c4c758 (diff) | |
download | metatile-50acc330c987a406715025d6dcead4b304223bb3.tar metatile-50acc330c987a406715025d6dcead4b304223bb3.zip |
shrink 'swap'
darcs-hash:20070430024813-9c5c1-28d697989294c4c5ce03e44553b75a8d7bc6c03e
-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 -- |