comparison modules/array.tp @ 342:884cd5d54c0f

Bugfix to array find:withDefault and a small optimization to array map
author Michael Pavone <pavone@retrodev.com>
date Sun, 05 Apr 2015 22:49:40 -0700
parents eef8a5cea812
children 810b6115c1d4 e857104bd183
comparison
equal deleted inserted replaced
341:6871e72b6db2 342:884cd5d54c0f
96 acc 96 acc
97 } 97 }
98 98
99 map <- :fun { 99 map <- :fun {
100 new <- #[] 100 new <- #[]
101 new resize: length
101 foreach: self :idx el { 102 foreach: self :idx el {
102 new append: (fun: el) 103 new append: (fun: el)
103 } 104 }
104 new 105 new
105 } 106 }
124 ret <- #{ 125 ret <- #{
125 key <- idx 126 key <- idx
126 value <- v 127 value <- v
127 } 128 }
128 idx <- l 129 idx <- l
130 } else: {
131 idx <- idx + 1
129 } 132 }
130 } 133 }
131 ret 134 ret
132 } 135 }
133 136
187 if: needsCopy? { 190 if: needsCopy? {
188 foreach: src :index val { 191 foreach: src :index val {
189 self set: index val 192 self set: index val
190 } 193 }
191 } 194 }
195 self
192 } 196 }
193 197
194 join <- :sep { 198 join <- :sep {
195 if: length > 0 { 199 if: length > 0 {
196 str <- string: (get: 0) 200 str <- string: (get: 0)