mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-25 08:43:46 -07:00
GridSelect: fix infiniteness problem with diamondRestrict
This commit is contained in:
@@ -79,17 +79,9 @@ diamondLayer n = let ul = [ (x,n-x) | x <- [0..n] ]
|
|||||||
diamond :: (Enum a, Num a) => [(a, a)]
|
diamond :: (Enum a, Num a) => [(a, a)]
|
||||||
diamond = concatMap diamondLayer [0..]
|
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 :: (Enum t, Num t, Ord t) => t -> t -> [(t, t)]
|
||||||
diamondRestrict x y = L.filter f diamond
|
diamondRestrict x y = L.filter (\(x',y') -> abs x' <= x && abs y' <= y) .
|
||||||
where f (x',y') = (x' <= x) &&
|
L.takeWhile (\(x',y') -> abs x' + abs y' <= x+y) $ diamond
|
||||||
(x' >= -x) &&
|
|
||||||
(y' <= y) &&
|
|
||||||
(y' >= -y)
|
|
||||||
|
|
||||||
tupadd :: (Num t1, Num t) => (t, t1) -> (t, t1) -> (t, t1)
|
tupadd :: (Num t1, Num t) => (t, t1) -> (t, t1) -> (t, t1)
|
||||||
tupadd (a,b) (c,d) = (a+c,b+d)
|
tupadd (a,b) (c,d) = (a+c,b+d)
|
||||||
|
Reference in New Issue
Block a user