# HG changeset patch # User Mike Pavone # Date 1376045922 25200 # Node ID 547153211389dc14d1ec7df829e8f94ce119ff70 # Parent 282b8056b702b11fe479143dd924e7b402baf952 Fix fold:with foldr:with and map in the array module diff -r 282b8056b702 -r 547153211389 modules/array.tp --- 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