Created
October 16, 2012 10:11
-
-
Save arturaz/3898478 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
intermediateLocations match { | |
case Nil => | |
f(oDeparture, tArrival) | |
case intermediate :: Nil => | |
f(oDeparture, iArrival(intermediate)) | |
f(iDeparture(intermediate), tArrival) | |
case _ => | |
f(oDeparture, iArrival(intermediateLocations.head)) | |
val last = intermediateLocations.sliding(2). | |
foldLeft(intermediateLocations.head) { | |
case (last, i1 :: i2 :: Nil) => | |
f(iDeparture(i1), iArrival(i2)) | |
i2 | |
case _ => sys.error("Non-exhaustive match here") | |
} | |
f(iDeparture(last), tArrival) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment