let rec line (x,y) (x',y') =
if abs (y'-y) > abs (x'-x)
then List.map (fun (y,x) -> (x,y)) (line (y,x) (y',x'))
else
if x > x'
then List.rev (line (x',y') (x,y))
else
let dx = x' - x in
let dy = abs (y' - y) in
let error = dx / 2 in
let ystep = (if y < y' then 1 else -1) in
let rec loop curx cury error =
if curx > x'
then []
else
let error' = error - dy in
if error' < 0
then (curx,cury) :: loop (curx+1) (cury+ystep) (error'+dx)
else (curx,cury) :: loop (curx+1) cury error'
in
loop x y error