package com.example.puzzles.lambda.scope data class Point(val x: Int, val y: Int) fun createRoutePlan() = buildList { var x = 1 for (y in 1..3) { add { Point(x, y) } x++ } } fun main() { for (nextLocation in createRoutePlan()) { println("Robot is moving to: " + nextLocation()) } }