RosettaCodeData/Task/Stack/Prolog/stack.pro

12 lines
272 B
Prolog
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
% push( ELEMENT, STACK, NEW )
% True if NEW is [ELEMENT|STACK]
push(ELEMENT,STACK,[ELEMENT|STACK]).
% pop( STACK, TOP, NEW )
% True if TOP and NEW are head and tail, respectively, of STACK
pop([TOP|STACK],TOP,STACK).
% empty( STACK )
% True if STACK is empty
empty([]).