Nemo #6461(2008/06/10 13:25 GMT) [ PostScript ] Rating0/0=0.00
PostScript で... 自分自身を食わせると 32 ( ) 293 10 [*] 61 101 (e) 51 114 (r) 48 116 (t) 47 111 (o) 42 112 (p) 34 くらいで、roll, copy, exch あたりのスタック操作命令が結構稼いでいるかと思います。 (t はコメントと変数名が...) 一般的な PostScript File の傾向は.... あまりに傾向が散らばりすぎてよくわかりません。 例えば PhotoShop で作成した巨大bitmap の eps file などでは、 コードよりも圧倒的に多量の embed されたデータが傾向を 決めることになってしまいます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
%!PS /CompareVal { % [I1 V1] [I2 V2] CompareXY [I1 V1] [I2 V2] V2-V1 2 copy 1 get exch 1 get sub } bind def /Sort { % [[x y] [x1 y1] Array Data ] {CompareFunction} Sort [ArrayData] cvx [ 3 -1 roll aload length % func -mark[- [] [] [] [] [] len -1 2 { % func -mark[- [] [] [] [] [] len2 -1 2 { 3 1 roll counttomark 1 add index exec %% Compare 0 lt { exch } if 3 -1 roll 1 roll } for counttomark 1 roll } for counttomark 1 roll ] exch pop } bind def /CountLetters { [ 0 1 255 { [ exch 0 ] } for ] { dup 2 index read { % array code get dup 1 get 1 add 1 exch put } { exit } ifelse } loop /CompareVal Sort exch pop exch pop } bind def /PrintResult { 0 1 255 { 2 copy get % [Array] i [I V] dup 0 get dup dup dup 3 string cvs print ( ) print 32 ge exch 127 lt and { % [Array] i [I V] I (( ) ) dup 1 4 -1 roll put print } { ([*] ) print pop } ifelse 1 get = pop } for pop } bind def %(countletter2.ps) (r) file CountLetters (%stdin) (r) file CountLetters PrintResult
Rating0/0=0.00-0+
[ reply ]
Nemo
#6461()
[
PostScript
]
Rating0/0=0.00
%!PS /CompareVal { % [I1 V1] [I2 V2] CompareXY [I1 V1] [I2 V2] V2-V1 2 copy 1 get exch 1 get sub } bind def /Sort { % [[x y] [x1 y1] Array Data ] {CompareFunction} Sort [ArrayData] cvx [ 3 -1 roll aload length % func -mark[- [] [] [] [] [] len -1 2 { % func -mark[- [] [] [] [] [] len2 -1 2 { 3 1 roll counttomark 1 add index exec %% Compare 0 lt { exch } if 3 -1 roll 1 roll } for counttomark 1 roll } for counttomark 1 roll ] exch pop } bind def /CountLetters { [ 0 1 255 { [ exch 0 ] } for ] { dup 2 index read { % array code get dup 1 get 1 add 1 exch put } { exit } ifelse } loop /CompareVal Sort exch pop exch pop } bind def /PrintResult { 0 1 255 { 2 copy get % [Array] i [I V] dup 0 get dup dup dup 3 string cvs print ( ) print 32 ge exch 127 lt and { % [Array] i [I V] I (( ) ) dup 1 4 -1 roll put print } { ([*] ) print pop } ifelse 1 get = pop } for pop } bind def %(countletter2.ps) (r) file CountLetters (%stdin) (r) file CountLetters PrintResultRating0/0=0.00-0+
[ reply ]