mirror of
https://github.com/github/semantic.git
synced 2024-12-27 00:44:57 +03:00
14 lines
299 B
Swift
14 lines
299 B
Swift
public enum Tree<A>: CustomStringConvertible {
|
|
case Leaf(A)
|
|
case Branch([Tree])
|
|
|
|
public var description: String {
|
|
switch self {
|
|
case let .Leaf(value):
|
|
return String(value)
|
|
case let .Branch(children):
|
|
return "(" + children.lazy.map { String($0) }.joinWithSeparator(" ") + ")"
|
|
}
|
|
}
|
|
}
|