Permalink
Browse files

Added method: STree.leaves_by_pred(..)

  • Loading branch information...
1 parent ff20062 commit 031640ef0fa6f28d59895675fa076e4ed7c61184 Erez Shin committed Mar 27, 2013
Showing with 4 additions and 1 deletion.
  1. +4 −1 plyplus/strees.py
View
@@ -116,7 +116,10 @@ def leaf(self, leaf_head, default=KeyError):
return r
def leaves(self, leaf_head):
- return STreeCollection(x for x in self.tail if x.head == leaf_head)
+ return self.leaves_by_pred(lambda x: x.head == leaf_head)
+
+ def leaves_by_pred(self, pred):
+ return STreeCollection(filter(pred, self.tail))
def calc_parents(self):
for i, kid in enumerate(self.tail):

0 comments on commit 031640e

Please sign in to comment.