I think there's an error in the first example.
Poly [1, -3, 0, 1]
Should be: Poly [1, 0, -3, 1]
EDIT: My mistake. Poly [1, -3, 0, 1]
Should be: Poly [1, 0, -3, 1]
EDIT: My mistake. eval =
v [] => 0
v x:xs => x + v * eval v xs
You do have to love how clean definition by cases makes these sorts of things.You either need to use foldr to defer the multiply-and-add until the end of the list is processed, or reverse the list before processing it.