Discussion
The two variables x and y both start out with a value of 1, and both increase by 1 on each iteration of the createRoutePlan loop—but the program’s output doesn’t contain a single line where x and y share the same value. Why do the two ways of counting loop iterations produce different outcomes?
Lambda List
The first important thing to understand about this puzzle is that the values we’re assembling via the buildList function aren’t Point objects—they’re lambda functions that will create Point objects.
You’d normally pass a new list item to add in parentheses: add(123) for a list of numbers, add("abc") for a list of strings, and so on. But in Puzzle 11, This Much Is True, you learned that when you use a lambda expression as the rightmost ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access