Mercurial > repos > tabletprog
comparison modules/array.tp @ 372:e857104bd183
Added reverse method to arrays
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 12 Aug 2015 19:16:41 -0700 |
parents | 884cd5d54c0f |
children | 93c28eee141e |
comparison
equal
deleted
inserted
replaced
371:625b0aa9c204 | 372:e857104bd183 |
---|---|
66 exit: 1 | 66 exit: 1 |
67 } | 67 } |
68 data <- tmp | 68 data <- tmp |
69 if: size > storage { | 69 if: size > storage { |
70 size <- storage | 70 size <- storage |
71 } | |
72 self | |
73 } | |
74 | |
75 llMessage: reverse withVars: { | |
76 front <- int32_t | |
77 back <- int32_t | |
78 tmpo <- object ptr | |
79 } andCode: { | |
80 front <- 0 | |
81 back <- size | |
82 while: { front < back } do: { | |
83 tmpo <- data get: front | |
84 data set: front (data get: back) | |
85 data set: back tmpo | |
86 front <- front + 1 | |
87 back <- back - 1 | |
71 } | 88 } |
72 self | 89 self |
73 } | 90 } |
74 | 91 |
75 llMessage: length withVars: { | 92 llMessage: length withVars: { |