Mercurial > repos > tabletprog
diff modules/list.tp @ 190:372cbd2cd243
Added reverse method to lists
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 26 Aug 2013 18:59:38 -0700 |
parents | 7e313849ab41 |
children | f3d5068cbd43 |
line wrap: on
line diff
--- a/modules/list.tp Mon Aug 26 18:23:05 2013 -0700 +++ b/modules/list.tp Mon Aug 26 18:59:38 2013 -0700 @@ -9,6 +9,7 @@ list node: val withTail: self } . <- :right { right } + reverse <- { self } join <- { "" } string <- { "[]" } print <- { print: string } @@ -52,6 +53,11 @@ node: val withTail: tail } } + reverse <- { + fold: [] with: :tail val { + node: val withTail: tail + } + } join <- :sep { _tail fold: (string: _val) with: :acc el { acc . sep . el