# HG changeset patch # User Mike Pavone # Date 1377566517 25200 # Node ID 7e313849ab41f11fd92bf6901868d47a7f611501 # Parent 810edf474f867e00fe30eea5ee7dffd94f0a17e9 Add join method to lists diff -r 810edf474f86 -r 7e313849ab41 modules/list.tp --- a/modules/list.tp Mon Aug 26 17:46:47 2013 -0700 +++ b/modules/list.tp Mon Aug 26 18:21:57 2013 -0700 @@ -9,6 +9,7 @@ list node: val withTail: self } . <- :right { right } + join <- { "" } string <- { "[]" } print <- { print: string } } @@ -51,6 +52,11 @@ node: val withTail: tail } } + join <- :sep { + _tail fold: (string: _val) with: :acc el { + acc . sep . el + } + } string <- { (fold: "[\n" with: :acc el { acc . " " . (string: el) . "\n"