forked from drasis/Dada-Engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dadaprolog.ps
58 lines (45 loc) · 1.11 KB
/
dadaprolog.ps
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
%!PS
%%Creator: acb
%%CreationDate: July 11, 1995
%% This is code for resolving recursive grammars in PostScript.
%% This code is part of the Dada Engine and copyright of Andrew C. Bulhak
%% You may use, distribute and modify this code in any way provided that
%% this copyright notice remains intact.
/bd {bind def} bind def
% choose an element from an array at random
% syntax: [array] choose elem
/choose {
dup length rand exch mod get
} bd
% concatenate an array of strings into a string
% [array] strcat (str)
/strcat {
dup
} bd
% syntax: name value conddef -
/conddef {
1 index where { pop pop pop } { def } ifelse
} bd
% (str) n repeat [array]
/rep {
dup 1 1 3 -1 roll {
pop exch dup 3 -1 roll
} for
[ exch 1 add 1 roll ] exch pop
} bd
% syntax: string star [strings]
/star {
0 { rand 5 mod 1 le {exit} if 1 add } loop
rep
% dup array exch 1 1 3 -1 roll
% { 1 sub 1 index exch 3 index put } for
% exch pop
} bd
/plus {
1 { rand 5 mod 1 le {exit} if 1 add } loop
rep
% dup array exch 1 1 3 -1 roll
% { 1 sub 1 index exch 3 index put } for
% exch pop
} bd
%% End of Dada Engine prologue