Stack: Difference between revisions

495 bytes added ,  16 years ago
JavaScript and Logo
(added ocaml)
(JavaScript and Logo)
Line 271:
}
}
 
=={{header|JavaScript}}==
The built-in Array class already has stack primitives.
var stack = [];
stack.push(1)
stack.push(2,3);
print(stack.pop()); // 3
print(stack.length); // 2, stack empty if 0
 
=={{header|Logo}}==
[[UCB Logo]] has built-in methods for treating lists as stacks. Since they are destructive, they take the name of the stack rather than the list itself.
make "stack []
push "stack 1
push "stack 2
push "stack 3
print pop "stack ; 3
print empty? :stack ; false
 
=={{header|OCaml}}==
Anonymous user