27 lines
973 B
Plaintext
27 lines
973 B
Plaintext
set_ns(rosettacode)_me();
|
|
|
|
add_stack({int},a)_values(1..4); // 1,2,3,4 (1 is first/bottom, 4 is last/top)
|
|
with_stack(a)_pop(); // 1,2,3
|
|
with_stack(a)_push()_v(5,6); // 1,2,3,5,6
|
|
|
|
add_var({int},b)_value(7);
|
|
with_stack(a)_push[b]; // 1,2,3,5,6,7
|
|
|
|
with_stack(a)_pluck()_at(2); // callee will return `with_stack(a)_err(pluck invalid with stack);`
|
|
|
|
me_msg()_stack(a)_top(); // "7"
|
|
me_msg()_stack(a)_last(); // "7"
|
|
me_msg()_stack(a)_peek(); // "7"
|
|
|
|
me_msg()_stack(a)_bottom(); // "1"
|
|
me_msg()_stack(a)_first(); // "1"
|
|
me_msg()_stack(a)_peer(); // "1"
|
|
|
|
me_msg()_stack(a)_isempty(); // "false"
|
|
with_stack(a)_empty();
|
|
with_stack(a)_msg()_isempty()_me(); // "true" (alternative syntax)
|
|
|
|
me_msg()_stack(a)_history()_all(); // returns th entire history of stack 'a' since its creation
|
|
|
|
reset_ns[];
|