Mercurial > repos > tabletprog
diff modules/dict.tp @ 202:cea671c4056c
Add map method to linear dict
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 28 Aug 2013 01:05:29 -0700 |
parents | a868a2aec930 |
children | 96fdc5b37ceb |
line wrap: on
line diff
--- a/modules/dict.tp Wed Aug 28 01:05:14 2013 -0700 +++ b/modules/dict.tp Wed Aug 28 01:05:29 2013 -0700 @@ -1,13 +1,11 @@ -#{ - //requires only that keys support equality - linear <- { +{ + linearWithEls <- :els { key:val <- :k v { #{ key <- k val <- v } } - els <- #[] find <- :tofind { idx <- 0 while: { @@ -64,8 +62,21 @@ } } + map <- :fun { + newels <- #[] + foreach: els :idx el { + newels append: (key: (el key) val: (fun: (el val))) + } + linearWithEls: newels + } + length <- { els length } } } - + #{ + //requires only that keys support equality + linear <- { + linearWithEls: #[] + } + } }