NB. The stack object template data =: '' stack =: monad define ('method' ; 'value') =. 2 take y. if. method match 'type' do. 'stack' elseif. method match 'emptyp' do. 0 = tally data elseif. method match 'push' do. for_effect_only data =: (box value) , data elseif. method match 'top' do. if. 0 = tally data do. 'top: stack is empty' else. open first data end. elseif. method match 'pop' do. if. 0 = tally data do. 'pop: stack is empty' else. for_effect_only data =: rest data end. elseif. method match 'size' do. tally data elseif. method match 'print' do. if. 0 = tally data do. 'print: stack is empty' else. for_effect_only display 'top of stack' s =. data while. 0 < tally s do. for_effect_only display open first s s =. rest s end. end. elseif. 1 do. root_object method ; value end. )