aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-06-01 19:50:42 +0200
committerDavid Roundy <droundy@darcs.net>2007-06-01 19:50:42 +0200
commit9f786a2867183f61a076ed37b49db9b9e2c8fdeb (patch)
tree43e6077b416be08dff21d75d441b9d646461aa2c
parentf425da01aab892dd2342eb211bd871ddf3c2c2ae (diff)
downloadXMonadContrib-9f786a2867183f61a076ed37b49db9b9e2c8fdeb.tar.gz
XMonadContrib-9f786a2867183f61a076ed37b49db9b9e2c8fdeb.tar.xz
XMonadContrib-9f786a2867183f61a076ed37b49db9b9e2c8fdeb.zip
improve changeMosaic.
darcs-hash:20070601175042-72aca-2fc051063bc744a4ecf322361e372473aad122c4.gz
-rw-r--r--Mosaic.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/Mosaic.hs b/Mosaic.hs
index fb8f544..2b1e96b 100644
--- a/Mosaic.hs
+++ b/Mosaic.hs
@@ -319,9 +319,17 @@ lengthM (M x) = sum $ map lengthM x
changeMosaic :: Mosaic a -> [Mosaic a]
changeMosaic (OM a) = []
-changeMosaic (M xs) = [makeM $ reverse xs] ++
- map makeM (concatenations xs) ++
- map makeM (splits xs) -- should also change the lower level
+changeMosaic (M xs) = map makeM (concatenations xs) ++
+ map makeM (splits xs) ++
+ map M (tryAll changeMosaic xs)
+
+tryAll :: (a -> [a]) -> [a] -> [[a]]
+tryAll _ [] = []
+tryAll f (x:xs) = map (:xs) (f x) ++ map (x:) (tryAll f xs)
+
+onceToEach :: (a -> a) -> [a] -> [[a]]
+onceToEach _ [] = []
+onceToEach f (x:xs) = (f x : xs) : map (x:) (onceToEach f xs)
splits :: [Mosaic a] -> [[Mosaic a]]
splits [] = []