Jump to content

Maxima/Algorithms

From Wikibooks, open books for an open world
Vectors made with Maxima CAS

Stack implementation using list:


/* create stack */
stack:[1];
/* push on stack */
stack:endcons(2,stack);
stack:endcons(3,stack);
block
(
  loop,
  stack:delete(last(stack),stack), /* pop from stack */
  disp(stack), /* display */
  if is(not emptyp(stack)) then go(loop)
);
stack;