Suppose I have a set {a, b, c, d}. I want to create a “path” from it, which is a generator that yields (a, b), then (b, c), then (c, d) (of course set is unordered, so any other path through the elements is acceptable).
What is the best way to do this?
Here’s an example using the
pairwise()recipe from http://docs.python.org/3/library/itertools.html#itertools-recipes