Hi Franck, what I was trying to do was take three items off the stack as a set of three onto a Stack array , such as [[ x, y, z], [ . . . ] , [ . . . ]] so that I can backtrack to that set of three at a later time. I needed them and all future sets of three kept as separate records on a Stack.
In my Initialization method there would be a line creating a Stack array:
- Code: Select all
Stack new to myList
Then in another method I would collect three parameters:
- Code: Select all
foobar method: collectThree \ x y z --
top as ArrayBuffer toggleThree apply
self mylist pop drop [ , , ] self myList push
;
Then in another BEGIN UNTIL looping function I could apply a test on three parameters and either toggle them and exchange them with the top Stack set of three or delete the top Stack set of three:
- Code: Select all
foobar method: crunchCollection \ x y z --
doWhile:
[ self testThree apply
ifTrue: [ self myList collectThree ]
else: [ self myList pop drop ]
self myList top testThree apply
]
;
In these methods that I use to go about collecting parameters into a stack, perform a conditional function and conditional loop, I've been using [ , , ] to collect the three items at a time as a record set.
I tend to get tunnel vision though, and it would be nice to know of other ways that I can push three parameters as a set into an array.
Bob