I started with Haskell a few days ago. I have the following code snippet (recursive function):
totaltime t [x] = 0
totaltime t route = tbd + totaltime (t+tbd) (tail(route))
where tbd = timebetweendepartures (fst(route!!0)) (fst(route!!1)) t (snd(route!!1))
"route" is a list of tuples, for example: [(3,1), (1,2), (5,2), (2,1)]
What I'm trying to do is to add (0,0) to the route before the function even starts doing what it should do.
So, if the parameter path is passed as [(3,1), (1,2), (5,2), (2,1)], then the function should get it as [(0,0), (3,1 ), (1,2), (5,2), (2,1)]
I could just do totaltime t ((0,0):route)
, but since the function is recursive, this will not work as intended.
Ideas are greatly appreciated!