Mercurial > repos > tabletprog
comparison modules/array.tp @ 260:56409de95f55
Untested implementation of filter for arrays
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 01 Jun 2014 22:39:25 -0700 |
parents | fd9005253861 |
children | bb4723fec05e |
comparison
equal
deleted
inserted
replaced
259:32964a4e7a33 | 260:56409de95f55 |
---|---|
101 new append: (fun: el) | 101 new append: (fun: el) |
102 } | 102 } |
103 new | 103 new |
104 } | 104 } |
105 | 105 |
106 filter <- :fun { | |
107 new <- #[] | |
108 foreach: self :idx el { | |
109 if: (fun: el) { | |
110 new append: el | |
111 } | |
112 } | |
113 new | |
114 } | |
115 | |
106 find:withDefault <- :pred :default{ | 116 find:withDefault <- :pred :default{ |
107 idx <- 0 | 117 idx <- 0 |
108 l <- length | 118 l <- length |
109 ret <- default | 119 ret <- default |
110 while: {idx < l} do: { | 120 while: {idx < l} do: { |