Skip to content

Instantly share code, notes, and snippets.

@thomasnield
Last active May 4, 2018 21:00
Show Gist options
  • Select an option

  • Save thomasnield/9c9cf99aaaee824c758f729111fc2d3d to your computer and use it in GitHub Desktop.

Select an option

Save thomasnield/9c9cf99aaaee824c758f729111fc2d3d to your computer and use it in GitHub Desktop.
test.kt
fun main(args: Array<String>) {
val markets = listOf(
OD("ABQ","PHX"),
OD("DAL", "HOU"),
OD("HOU", "PHX")
)
val distinctStations = markets.asSequence()
.flatMap { sequenceOf(it.orig, it.dest) }
.distinct()
.toList()
println(distinctStations)
}
data class OD(val orig: String, val dest: String)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment