[Haskell-cafe] Re: Need feedback on my Haskell code

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Wed Jul 29 05:00:54 EDT 2009


CK Kashyap <ck_kashyap at yahoo.com> writes:

> line' (x1, y1) (x2, y2) deltax deltay ystep isSteep error
>   | x1 == x2 = if isSteep then [(y1, x1)] else [(x1, y1)]
>   | isSteep =
>     (y1, x1) :
>       line' (newX, newY) (x2, y2) deltax deltay ystep isSteep newError
>   | otherwise =
>     (x1, y1) :
>       line' (newX, newY) (x2, y2) deltax deltay ystep isSteep newError
>   where newX = x1 + 1
>         tempError = error + deltay
>         (newY, newError)
>           = if (2 * tempError) >= deltax then
>               (y1 + ystep, tempError - deltax) else (y1, tempError)

It's early in my day, so I'm not very awake, but this looks like it
could be an iterate or something like that, rather than explicit
recursion.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Haskell-Cafe mailing list