File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ assert Stack.pop(stack) == Some(2)
5050assert Stack.pop(stack) == Some(1)
5151assert Stack.pop(stack) == None
5252
53+ let stack = Stack.makeSized(0)
54+ Stack.push(0, stack)
55+ let stack2 = Stack.makeSized(1)
56+ Stack.push(0, stack2)
57+ assert stack == stack2
58+
5359module Immutable {
5460 from Stack use { Immutable as Stack }
5561
Original file line number Diff line number Diff line change @@ -89,7 +89,9 @@ provide let peek = stack => {
8989 */
9090provide let push = (value, stack) => {
9191 let arrLen = Array.length(stack.array)
92- if (stack.size == arrLen) {
92+ if (arrLen == 0) {
93+ stack.array = Array.make(1, None)
94+ } else if (stack.size == arrLen) {
9395 let newArray = Array.make(stack.size * 2, None)
9496 for (let mut i = 0; i < arrLen; i += 1) {
9597 newArray[i] = stack.array[i]
You can’t perform that action at this time.
0 commit comments