# HG changeset patch # User Michael Pavone # Date 1406944501 25200 # Node ID ed908b7fcec6b0cacb915e6e387f4f3bc125840f # Parent 647f7a2d253b2debca9638732e6fc8b44aa38bd8 Add find method to list diff -r 647f7a2d253b -r ed908b7fcec6 modules/list.tp --- a/modules/list.tp Thu Jul 24 23:55:59 2014 -0700 +++ b/modules/list.tp Fri Aug 01 18:55:01 2014 -0700 @@ -12,6 +12,7 @@ reverse <- { self } join <- { "" } contains? <- :val { false } + find <- :pred { option none } string <- { "[]" } print <- { print: string } jsonEncode <- { "[]" } @@ -72,6 +73,15 @@ _tail contains?: val } } + + find <- :pred { + if: (pred: _val) { + option value: _val + } else: { + _tail find: pred + } + } + string <- { (fold: "[\n" with: :acc el { acc . " " . (string: el) . "\n"