Closures in Swift are a great feature and are useful for tasks such as network callbacks, notification subscription, and providing an alternative to the delegate pattern.
Recently, I discovered that code as inconspicuous as a
&& (and) conditional could also leverage this feature.
In the last post, we explored how a graph can be represented using an adjacency list. We’ll now look at how an adjacency matrix can also be used.
There are two popular traversal algorithms for graph traversal: Depth First Search (DFS) and Breadth First Search (BFS). Both of which have lots of applications.
I believe that UIView’s private function:
recursiveDescription is an application of DFS and I’ll attempt to re-create it with that assumption.