
I made a mistake in copying the original code.
The correct version is:
line (sx, sy) (tx, ty)
| abs (sx - tx) > abs (sy - ty) =
zip xs [round (sy + (sy - ty) * x / xd) | x <- [0 .. xd]]
| otherwise =
zip [round (sx + (sx - tx) * y / yd) | y <- [0 .. yd]] ys
where
xs = target sx tx
ys = target sy ty
xd = abs (sx - tx)
yd = abs (sy - ty)
On Tue, Feb 9, 2010 at 4:40 PM, han
I have this code:
line (sx, sy) (tx, ty) | abs (sx - tx) > abs (sy - ty) = zip xs [(sy + (sy - ty) * x / xd) | x <- [0 .. xd]] | otherwise = zip [(sx + (sx - tx) * y / yd) | y <- [0 .. yd]] ys where xs = target sx tx ys = target sy ty xd = abs (sx - tx) yd = abs (sy - ty)
It currently has the inferred type signature of
(Integral b, RealFrac b) => (b, b) -> (b, b) -> [(b, b)]
and I want it to be
(Int, Int) -> (Int, Int) -> [(Int, Int)]
which, when coerced, causes an error.
Any idea?