diff options
author | Roman Cheplyaka <roma@ro-che.info> | 2008-11-11 06:53:50 +0100 |
---|---|---|
committer | Roman Cheplyaka <roma@ro-che.info> | 2008-11-11 06:53:50 +0100 |
commit | 9300fcdeced8eacd6eca4c4e2ffc31bd977e3aee (patch) | |
tree | 23c93b9c422c6976ef776254df2bb3f43b333909 | |
parent | b3e300a0ad4d48ffadb90337eed5bb8581d23a76 (diff) | |
download | XMonadContrib-9300fcdeced8eacd6eca4c4e2ffc31bd977e3aee.tar.gz XMonadContrib-9300fcdeced8eacd6eca4c4e2ffc31bd977e3aee.tar.xz XMonadContrib-9300fcdeced8eacd6eca4c4e2ffc31bd977e3aee.zip |
GridSelect: fix infiniteness problem with diamondRestrict
darcs-hash:20081111055350-3ebed-ae3b880139b196938fbc532196dc13ec0c46cd1c.gz
Diffstat (limited to '')
-rw-r--r-- | XMonad/Actions/GridSelect.hs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/XMonad/Actions/GridSelect.hs b/XMonad/Actions/GridSelect.hs index bacea13..5d8307d 100644 --- a/XMonad/Actions/GridSelect.hs +++ b/XMonad/Actions/GridSelect.hs @@ -79,17 +79,9 @@ diamondLayer n = let ul = [ (x,n-x) | x <- [0..n] ] diamond :: (Enum a, Num a) => [(a, a)] diamond = concatMap diamondLayer [0..] - --- FIXME this function returns a list an infinite list with finite --- elements, so going beyond the last proper element causes a never --- ending computation. - diamondRestrict :: (Enum t, Num t, Ord t) => t -> t -> [(t, t)] -diamondRestrict x y = L.filter f diamond - where f (x',y') = (x' <= x) && - (x' >= -x) && - (y' <= y) && - (y' >= -y) +diamondRestrict x y = L.filter (\(x',y') -> abs x' <= x && abs y' <= y) . + L.takeWhile (\(x',y') -> abs x' + abs y' <= x+y) $ diamond tupadd :: (Num t1, Num t) => (t, t1) -> (t, t1) -> (t, t1) tupadd (a,b) (c,d) = (a+c,b+d) |