5 normalize l = go (length l)
7 go i = if i > 0 && l!(i-1)==zero
11 instance (Additive a) => Additive (Poly a) where
26 instance (Ring a) => Ring (Poly a) where
28 neg (Poly l) = Poly (map neg l)
32 then [ segSum n 0 n | n <- [0 ..aDeg] ]
33 + [ segSum n 0 aDeg | n <- [aDeg+1..bDeg] ]
34 + [ segSum n (n-bDeg) aDeg | n <- [bDeg+1..sumDeg] ]
35 else [ segSum n 0 n | n <- [0 ..bDeg] ]
36 + [ segSum n (n-bDeg) n | n <- [bDeg+1..aDeg] ]
37 + [ segSum n (n-bDeg) aDeg | n <- [aDeg+1..sumDeg] ]
43 segSum n low high = sum [ a!i * b!(n-i) | i <- [low..high] ]
44 fromInteger x = Poly [fromInteger x]
46 a = Poly [4.0,5.0,8.0,3.0,2.0,1.0]
47 b = Poly [1.0,0.0,2.0,1.0]
48 main = a * a + a * b + b * a + b * b - (a+b)*(a+b)