# HG changeset patch # User Mike Pavone # Date 1377677129 25200 # Node ID cea671c4056c253b2ba5a20a21a3f30568aeb2f5 # Parent d2e0664ba73ecdfaff119f481a1bf51cc5fdb8bb Add map method to linear dict diff -r d2e0664ba73e -r cea671c4056c modules/dict.tp --- 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: #[] + } + } }