Haskell - Turning a list into a list of object with index
You can use zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
to enumerate over two lists concurrently, and apply a function on the two items of the list. You thus can construct the Point
s with:
zipWith Point [0 ..] myCoords
with myCoords
the list of coordinates, so for the sample data, myCoords
is [[5.8,2.7,4.1,1.0],[6.2,2.2,4.5,1.5],[5.6,2.5,3.9,1.1]]
.