예제 #1
0
 //return all the nodes in a given expression tree
 public static IEnumerable <EditableExpression> Nodes(this EditableExpression source)
 {
     //i.e. left, right, body, etc.
     foreach (EditableExpression linkNode in source.LinkNodes())
     {
         //recursive call to get the nodes from the tree, until you hit terminals
         foreach (EditableExpression subNode in linkNode.Nodes())
         {
             yield return(subNode);
         }
     }
     yield return(source); //return the root of this most recent call
 }