Mercurial > repos > tabletprog
changeset 144:547153211389
Fix fold:with foldr:with and map in the array module
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 09 Aug 2013 03:58:42 -0700 |
parents | 282b8056b702 |
children | 7db37f040a6f |
files | modules/array.tp |
diffstat | 1 files changed, 13 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/modules/array.tp Fri Aug 09 03:58:08 2013 -0700 +++ b/modules/array.tp Fri Aug 09 03:58:42 2013 -0700 @@ -11,7 +11,7 @@ false } } - + llMessage: set withVars: { index <- obj_int32 ptr value <- object ptr @@ -21,7 +21,7 @@ } self } - + llMessage: foreach withVars: { clos <- lambda ptr i <- uint32_t @@ -36,7 +36,7 @@ } self } - + llMessage: append withVars: { value <- object ptr tmp <- (object ptr) ptr @@ -54,7 +54,7 @@ size <- size + 1 self } - + llMessage: length withVars: { intret <- obj_int32 ptr } andCode: { @@ -62,27 +62,30 @@ intret num!: size intret } - + fold:with <- :acc :fun { foreach: self :idx el { - fun: acc el + acc <- fun: acc el } + acc } - + foldr:with <- :acc :fun { idx <- length - 1 while: {idx >= 0} do: { - fun: acc (get: idx) + acc <- fun: acc (get: idx) } + acc } - + map <- :fun { new <- #[] foreach: self :idx el { new append: (fun: el) } + new } - + find:withDefault <- :pred :default{ idx <- 0 l <- length