Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #1730
| Newsgroups | comp.lang.postscript |
|---|---|
| Date | 2013-11-15 09:16 -0800 |
| References | <747c7407-c3e4-4c3b-9155-84d220140367@googlegroups.com> <d3da1824-e599-4d76-be1c-31b1cd54eac4@googlegroups.com> <0e9107ef-3a0b-4ef8-ac43-ed1b7667c2e2@googlegroups.com> |
| Message-ID | <1df47488-9913-4129-aac0-615ef2cfd6be@googlegroups.com> (permalink) |
| Subject | Re: GOLF! abbreviated system names |
| From | luser- -droog <mijoryx@yahoo.com> |
On Thursday, August 29, 2013 2:51:01 AM UTC-5, luser- -droog wrote:
> Clean-ed up a bit, with some brief exposition.
Optimized up a bit. Replaced linear-lookup error handler
with a constructed dictionary.
%!
%abbr.ps
% abbreviated system names
% exports (defines) 1 procedure:
% - ABBR dict
% which generates an abbreviation dictionary.
%
% This allows you to use alphabetic abbreviations for
% standard systemdict names, suxh as:
%
% a %= abs
% ad %= add
% mu %= mul
% pr %= print
% g %= ge
% f %= file
% etc. Check PLRM 2ed or 3ed, Appendix F Encoded System Names
/ABBR {
2 dict begin
225 -1 0 { % generate defs in reverse alphabetic (numeric) order
%dup =only( )=only
<910> dup 1 4 3 roll put cvx exec
%dup =only( )=only
cvx dup =string cvs % op str
%pstack()= stop
exch
dup { currentdict end exch load
} stopped { pop begin cvlit }{ exch begin exch pop } ifelse
exch
%pstack() = %stop
0
1 1 3 index length
%1 sub
{ % opname str 0 i
3 copy getinterval % opname str 0 i str[0,i]
%dup =only( )=only
cvn 4 index def
pop % opname str 0
} for
%()=
pop pop pop
} for
0 1 225 { % print out the shortest ABBR name for each system name.
dup =only( )=only
<910> dup 1 4 3 roll put cvx exec % opname
dup =only( )=only
cvx dup =string cvs
exch
dup { currentdict end exch load
} stopped { pop begin cvlit }{ exch begin exch pop } ifelse
exch
0
{
1 1 3 index length 1 sub {
3 copy getinterval
dup cvn load % opname str 0 i str[0,i] loaded
5 index eq {
=only( )=only
pop
stop
}{
pop pop
} ifelse
} for
} stopped pop
()=
pop pop pop
} for
/ABBR where pop /ABBR currentdict put %memo
currentdict end
} bind def
currentfile flushfile % comment-out this line to test
ABBR begin
2 3 ad
4 mu
=string cvs pr
(\n)pr % prints "20"
end
ABBR begin
%!
%Sierpinski Triangle via L-system
<</F{F - G + F + G - F}/G{G G}>>b
{F - G - G}7{[ex{du w{ex get al po}if}fora]}rep
cvx<</F{3 0 rl}/G 1 in/-{120 rot}/+{-120 rot}>>b
100 200 mov exe fill showp
end
Back to comp.lang.postscript | Previous | Next — Previous in thread | Find similar
GOLF! abbreviated system names luser- -droog <mijoryx@yahoo.com> - 2013-08-28 00:23 -0700
Re: GOLF! abbreviated system names luser- -droog <mijoryx@yahoo.com> - 2013-08-28 00:55 -0700
Re: GOLF! abbreviated system names luser- -droog <mijoryx@yahoo.com> - 2013-08-29 00:51 -0700
Re: GOLF! abbreviated system names luser- -droog <mijoryx@yahoo.com> - 2013-11-15 09:16 -0800
csiph-web