|
Revision 4, 2.1 kB
(checked in by jms, 8 months ago)
|
Chargement de jps2ps dans le SVN.
|
| Line | |
|---|
| 1 |
%% syntaxe : [x1 ... xn] (f) apply --> [f(x1) ... f(xn)] |
|---|
| 2 |
/apply { |
|---|
| 3 |
3 dict begin |
|---|
| 4 |
dup isstring |
|---|
| 5 |
{/fonction exch cvx def} |
|---|
| 6 |
{/fonction exch def} |
|---|
| 7 |
ifelse |
|---|
| 8 |
/liste exch def |
|---|
| 9 |
/@i 0 def |
|---|
| 10 |
[ |
|---|
| 11 |
liste length { |
|---|
| 12 |
liste @i get fonction |
|---|
| 13 |
/@i @i 1 add store |
|---|
| 14 |
} repeat |
|---|
| 15 |
counttomark |
|---|
| 16 |
0 eq |
|---|
| 17 |
{pop} |
|---|
| 18 |
{]} |
|---|
| 19 |
ifelse |
|---|
| 20 |
end |
|---|
| 21 |
} def |
|---|
| 22 |
|
|---|
| 23 |
%% syntaxe : [x1 ... xn] (f) papply |
|---|
| 24 |
/papply { |
|---|
| 25 |
3 dict begin |
|---|
| 26 |
dup isstring |
|---|
| 27 |
{/fonction exch cvx def} |
|---|
| 28 |
{/fonction exch def} |
|---|
| 29 |
ifelse |
|---|
| 30 |
/liste exch def |
|---|
| 31 |
/@i 0 def |
|---|
| 32 |
[ |
|---|
| 33 |
liste length 2 idiv { |
|---|
| 34 |
liste @i get |
|---|
| 35 |
liste @i 1 add get |
|---|
| 36 |
fonction |
|---|
| 37 |
/@i @i 2 add store |
|---|
| 38 |
} repeat |
|---|
| 39 |
counttomark |
|---|
| 40 |
0 eq |
|---|
| 41 |
{pop} |
|---|
| 42 |
{]} |
|---|
| 43 |
ifelse |
|---|
| 44 |
end |
|---|
| 45 |
} def |
|---|
| 46 |
|
|---|
| 47 |
%% syntaxe : [x1 ... xn] (f) capply |
|---|
| 48 |
/capply { |
|---|
| 49 |
3 dict begin |
|---|
| 50 |
dup isstring |
|---|
| 51 |
{/fonction exch cvx def} |
|---|
| 52 |
{/fonction exch def} |
|---|
| 53 |
ifelse |
|---|
| 54 |
/liste exch def |
|---|
| 55 |
/@i 0 def |
|---|
| 56 |
[ |
|---|
| 57 |
liste length 3 idiv { |
|---|
| 58 |
liste @i get |
|---|
| 59 |
liste @i 1 add get |
|---|
| 60 |
liste @i 2 add get |
|---|
| 61 |
fonction |
|---|
| 62 |
/@i @i 3 add store |
|---|
| 63 |
} repeat |
|---|
| 64 |
counttomark |
|---|
| 65 |
0 eq |
|---|
| 66 |
{pop} |
|---|
| 67 |
{]} |
|---|
| 68 |
ifelse |
|---|
| 69 |
end |
|---|
| 70 |
} def |
|---|
| 71 |
|
|---|
| 72 |
%% syntaxe : [x1 ... xn] (f) dapply |
|---|
| 73 |
/dapply { |
|---|
| 74 |
3 dict begin |
|---|
| 75 |
dup isstring |
|---|
| 76 |
{/fonction exch cvx def} |
|---|
| 77 |
{/fonction exch def} |
|---|
| 78 |
ifelse |
|---|
| 79 |
/liste exch def |
|---|
| 80 |
/@i 0 def |
|---|
| 81 |
[ |
|---|
| 82 |
liste length 4 idiv { |
|---|
| 83 |
liste @i get |
|---|
| 84 |
liste @i 1 add get |
|---|
| 85 |
liste @i 2 add get |
|---|
| 86 |
liste @i 3 add get |
|---|
| 87 |
fonction |
|---|
| 88 |
/@i @i 4 add store |
|---|
| 89 |
} repeat |
|---|
| 90 |
counttomark |
|---|
| 91 |
0 eq |
|---|
| 92 |
{pop} |
|---|
| 93 |
{]} |
|---|
| 94 |
ifelse |
|---|
| 95 |
end |
|---|
| 96 |
} def |
|---|
| 97 |
|
|---|
| 98 |
%% syntaxe : [x1 ... xn] (f) n1 n2 Apply |
|---|
| 99 |
%% f prend n2 parametres, et on decale de n1 a chaque |
|---|
| 100 |
%% iteration. ainsi le 1er parametre de la 2eme iteration est x_(1+n1) |
|---|
| 101 |
/Apply { |
|---|
| 102 |
6 dict begin |
|---|
| 103 |
/n2 exch def |
|---|
| 104 |
/n1 exch def |
|---|
| 105 |
dup isstring |
|---|
| 106 |
{/fonction exch cvx def} |
|---|
| 107 |
{/fonction exch def} |
|---|
| 108 |
ifelse |
|---|
| 109 |
/liste exch def |
|---|
| 110 |
/@i 0 def |
|---|
| 111 |
[ |
|---|
| 112 |
liste length n1 add n2 sub n1 idiv { |
|---|
| 113 |
/@j 0 def |
|---|
| 114 |
n2 { |
|---|
| 115 |
liste @i @j add get |
|---|
| 116 |
/@j @j 1 add store |
|---|
| 117 |
} repeat |
|---|
| 118 |
fonction |
|---|
| 119 |
/@i @i n1 add store |
|---|
| 120 |
} repeat |
|---|
| 121 |
counttomark |
|---|
| 122 |
0 eq |
|---|
| 123 |
{pop} |
|---|
| 124 |
{]} |
|---|
| 125 |
ifelse |
|---|
| 126 |
end |
|---|
| 127 |
} def |
|---|