Mercurial > repos > tabletprog
comparison 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 |
comparison
equal
deleted
inserted
replaced
189:a45e535f7742 | 190:372cbd2cd243 |
---|---|
7 map <- :fun { self } | 7 map <- :fun { self } |
8 | <- :val { | 8 | <- :val { |
9 list node: val withTail: self | 9 list node: val withTail: self |
10 } | 10 } |
11 . <- :right { right } | 11 . <- :right { right } |
12 reverse <- { self } | |
12 join <- { "" } | 13 join <- { "" } |
13 string <- { "[]" } | 14 string <- { "[]" } |
14 print <- { print: string } | 15 print <- { print: string } |
15 } | 16 } |
16 #{ | 17 #{ |
50 . <- :right { | 51 . <- :right { |
51 foldr: right with: :tail val { | 52 foldr: right with: :tail val { |
52 node: val withTail: tail | 53 node: val withTail: tail |
53 } | 54 } |
54 } | 55 } |
56 reverse <- { | |
57 fold: [] with: :tail val { | |
58 node: val withTail: tail | |
59 } | |
60 } | |
55 join <- :sep { | 61 join <- :sep { |
56 _tail fold: (string: _val) with: :acc el { | 62 _tail fold: (string: _val) with: :acc el { |
57 acc . sep . el | 63 acc . sep . el |
58 } | 64 } |
59 } | 65 } |