% --- start of displayed preamble in the book --- pair _cp; % current point pair _cps[]; % stack of current points numeric _ncps; _ncps=0; def PUSH = _cps[_ncps]:=_cp; _ncps:=_ncps+1; enddef; def POP = if _ncps>0: _ncps:=_ncps-1; _cp:=_cps[_ncps]; else: message "YOU CAN'T POP HERE"; stophere fi; enddef; def initdrawing=_cp:=origin; enddef; def mv(expr d,a)=_cp:=_cp+d*dir(a);enddef; def lineto(expr d,a) text options= draw _cp--(_cp+d*dir(a)) options;mv(d,a);enddef; def mvright(expr d)=mv(d,0);enddef; def mvleft(expr d)=mvright(-d);enddef; def mvup(expr d)=mv(d,90);enddef; def mvdown(expr d)=mvup(-d);enddef; def lineright(expr d) text options=lineto(d,0) options;enddef; def lineleft(expr d) text options=lineright(-d) options;enddef; def lineup(expr d) text options=lineto(d,90) options;enddef; def linedown(expr d) text options=lineup(-d) options;enddef; % --- end of displayed preamble in the book --- defaultfont:="ptmr8r"; warningcheck:=0; beginfig(1) numeric u; u=1cm; initdrawing; lineright(3u);lineup(2u); PUSH lineto(1.5u/cosd(30),150); lineto(1.5u/cosd(30),210); POP lineleft(3u);linedown(2u); mvright(u); lineup(1.5u);lineright(u);linedown(1.5u); endfig; end;