Mercurial > repos > icfp2012
diff src/sim.tp @ 31:f7a1daaec925
Use dictionary
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 14 Jul 2012 21:27:36 -0700 |
parents | 031d46ff76a9 |
children | 0a55ee387d69 |
line wrap: on
line diff
--- a/src/sim.tp Sat Jul 14 20:34:40 2012 -0700 +++ b/src/sim.tp Sat Jul 14 21:27:36 2012 -0700 @@ -14,34 +14,20 @@ } makeCellTypes <- { - allid <- #[] - allobj <- #[] + typedict <- dict linear new <- :idStr { ret <- #{ id <- (idStr byte: 0) str <- idStr isrobot <- { false } } - allobj append: ret - allid append: (ret id) + typedict set: (ret id) ret ret } #{ find <- :id { if: id = ("R" byte: 0) { robot: } else: { - index <- 0 - while: { - if: index < (allid length) { - (allid get: index) != id - } - } do: { - index <- index + 1 - } - if: index < (allid length) { - allobj get: index - } else: { - empty - } + typedict get: id withDefault: empty } } wall <- new: "#"