Mercurial > repos > tabletprog
changeset 190:372cbd2cd243
Added reverse method to lists
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 26 Aug 2013 18:59:38 -0700 |
parents | a45e535f7742 |
children | abde5d2918cf |
files | modules/list.tp |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
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