Skip to content

Commit

Permalink
Add selfAndParents convenience helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Nov 4, 2024
1 parent f46864f commit 460753c
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ trait Node {

// first is closest
def parents: List[Node] = List.unfold(parent)(_.map(p => ((p, p.parent))))
def selfAndParents: List[Node] = this :: parents

def visit[A](visitor: Node.Visitor[A]): A = visitor.onNode(this, this.children)

Expand Down

0 comments on commit 460753c

Please sign in to comment.