Ville Tirronen
13.10.2011
README vastaamaan ryhmän aitoa kokoonpanoa.
data Rectangle = R Int Int Int Int deriving (Eq,Show)
mkR a b c d = R (min a c) (min b d) (max a c) (max b d)
instance Arbitrary (Rectangle)
where
arbitrary = mkR <$> choose (-100,100) <*> choose (-100,100)
<*> choose (-100,100) <*> choose (-100,100)
areaR (R l t r b) = (r-l)*(b-t)
intersect1D (x,y) (u,w) =
not $ (x <= min u w && y <= min u w)
|| (x >= max u w && y >= max u w)
intersects re1@(R l1 t1 r1 b1) re2@(R l2 t2 r2 b2)
| areaR re1 > 0 && areaR re2 > 0
= intersect1D (l1,r1) (l2,r2) && intersect1D (t1,b1) (t2,b2)
| otherwise = False
intersection (R l1 t1 r1 b1) (R l2 t2 r2 b2)
= R (max l1 l2) (max t1 t2)
(min r1 r2) (min b1 b2)
Suorakaide + leikkaus[Suorakaide] + yhdisteLMitattuAla aalaS ja alaLleikkausS ja leikkausLyhdiste ja yhdisteLala x > 0leikkaus a b == leikkaus a (leikkaus a b) (Idempotenssi)leikkaus a b == leikkaus b a (kommutatiivisuus)yhdisteL (yhdiste a b) (A a) == yhdiste a(Ord a) saatte arvon () mikä ei hirveästi testaa mitäänMonad & Applicative-luokista.