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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
\documentclass{article}
\usepackage{open-axiom}
\begin{document}
\title{\$SPAD/src/algebra out.spad}
\author{Stephen M. Watt, Robert S. Sutor}
\maketitle
\begin{abstract}
\end{abstract}
\tableofcontents
\eject
\section{package OUT OutputPackage}
<<package OUT OutputPackage>>=
import Void
import String
import OutputForm
import List Any
)abbrev package OUT OutputPackage
++ Author: Stephen M. Watt
++ Date Created: February 1986
++ Date Last Updated: October 27 1995 (MCD)
++ Basic Operations: output
++ Related Constructors: OutputForm
++ Also See:
++ AMS Classifications:
++ Keywords:
++ References:
++ Description: OutPackage allows pretty-printing from programs.
OutputPackage: with
output: String -> Void
++ output(s) displays the string s on the ``algebra output''
++ stream, as defined by \spadsyscom{set output algebra}.
output: OutputForm -> Void
++ output(x) displays the output form x on the
++ ``algebra output'' stream, as defined by
++ \spadsyscom{set output algebra}.
output: (String, OutputForm) -> Void
++ output(s,x) displays the string s followed by the form x
++ on the ``algebra output'' stream, as defined by
++ \spadsyscom{set output algebra}.
outputList: (List Any) -> Void
++ outputList(l) displays the concatenated components of the
++ list l on the ``algebra output'' stream, as defined by
++ \spadsyscom{set output algebra}; quotes are stripped
++ from strings.
== add
--ExpressionPackage()
E ==> OutputForm
putout ==> mathprint$Lisp
s: String
e: OutputForm
l: List Any
output e ==
mathprint(e)$Lisp
output s ==
output(s:E)
output(s,e) ==
output blankSeparate [s:E, e]
outputList(l) == -- MGR
output hconcat
[if retractable?(x)$AnyFunctions1(String) then
message(retract(x)$AnyFunctions1(String))$OutputForm
else
x::OutputForm
for x in l]
@
\section{package SPECOUT SpecialOutputPackage}
<<package SPECOUT SpecialOutputPackage>>=
)abbrev package SPECOUT SpecialOutputPackage
++ Author: Stephen M. Watt
++ Date Created: September 1986
++ Date Last Updated: May 23, 1991
++ Basic Operations: outputAsFortran, outputAsScript, outputAsTex
++ Related Constructors:
++ Also See:
++ AMS Classifications:
++ Keywords:
++ References:
++ Description: SpecialOutputPackage allows FORTRAN, Tex and
++ Script Formula Formatter output from programs.
SpecialOutputPackage: public == private where
public == with
outputAsFortran: (String,OutputForm) -> Void
++ outputAsFortran(v,o) sends output v = o in FORTRAN format
++ to the destination defined by \spadsyscom{set output fortran}.
outputAsFortran: OutputForm -> Void
++ outputAsFortran(o) sends output o in FORTRAN format.
outputAsScript: OutputForm -> Void
++ outputAsScript(o) sends output o in Script Formula Formatter format
++ to the destination defined by \spadsyscom{set output formula}.
outputAsTex: OutputForm -> Void
++ outputAsTex(o) sends output o in Tex format to the destination
++ defined by \spadsyscom{set output tex}.
outputAsFortran: List OutputForm -> Void
++ outputAsFortran(l) sends (for each expression in the list l)
++ output in FORTRAN format to the destination defined by
++ \spadsyscom{set output fortran}.
outputAsScript: List OutputForm -> Void
++ outputAsScript(l) sends (for each expression in the list l)
++ output in Script Formula Formatter format to the destination defined.
++ by \spadsyscom{set output forumula}.
outputAsTex: List OutputForm -> Void
++ outputAsTex(l) sends (for each expression in the list l)
++ output in Tex format to the destination as defined by
++ \spadsyscom{set output tex}.
private == add
e : OutputForm
l : List OutputForm
var : String
--ExpressionPackage()
juxtaposeTerms: List OutputForm -> OutputForm
juxtaposeTerms l == blankSeparate l
outputAsFortran e ==
dispfortexp$Lisp e
outputAsFortran(var,e) ==
e := var::Symbol::OutputForm = e
dispfortexp(e)$Lisp
outputAsFortran l ==
dispfortexp$Lisp juxtaposeTerms l
outputAsScript e ==
formulaFormat$Lisp e
outputAsScript l ==
formulaFormat$Lisp juxtaposeTerms l
outputAsTex e ==
texFormat$Lisp e
outputAsTex l ==
texFormat$Lisp juxtaposeTerms l
@
\section{package DISPLAY DisplayPackage}
<<package DISPLAY DisplayPackage>>=
)abbrev package DISPLAY DisplayPackage
++ Author: Robert S. Sutor
++ Date Created: September 1986
++ Date Last Updated:
++ Basic Operations: bright, newLine, copies, center, say, sayLength
++ Related Constructors:
++ Also See:
++ AMS Classifications:
++ Keywords:
++ References:
++ Description: DisplayPackage allows one to print strings in a nice manner,
++ including highlighting substrings.
DisplayPackage: public == private where
I ==> Integer
L ==> List
S ==> String
RECLR ==> Record(lhs : S, rhs : S)
public == with
bright: S -> L S
++ bright(s) sets the font property of the string s to bold-face type.
bright: L S -> L S
++ bright(l) sets the font property of a list of strings, l, to
++ bold-face type.
newLine: () -> S
++ newLine() sends a new line command to output.
copies: (I,S) -> S
++ copies(i,s) will take a string s and create a new string composed of
++ i copies of s.
center: (S,I,S) -> S
++ center(s,i,s) takes the first string s, and centers it within a string
++ of length i, in which the other elements of the string are composed
++ of as many replications as possible of the second indicated string, s
++ which must have a length greater than that of an empty string.
center: (L S,I,S) -> L S
++ center(l,i,s) takes a list of strings l, and centers them within a
++ list of strings which is i characters long, in which the remaining
++ spaces are filled with strings composed of as many repetitions as
++ possible of the last string parameter s.
say: S -> Void
++ say(s) sends a string s to output.
say: L S -> Void
++ say(l) sends a list of strings l to output.
sayLength: S -> I
++ sayLength(s) returns the length of a string s as an integer.
sayLength: L S -> I
++ sayLength(l) returns the length of a list of strings l as an integer.
private == add
--StringManipulations()
center0: (I,I,S) -> RECLR
s : S
l : L S
HION : S := "%b"
HIOFF : S := "%d"
NEWLINE : S := "%l"
bright s == [HION,s,HIOFF]$(L S)
bright l == cons(HION,append(l,list HIOFF))
newLine() == NEWLINE
copies(n : I, s : S) ==
n < 1 => ""
n = 1 => s
t : S := copies(n quo 2, s)
odd? n => concat [s,t,t]
concat [t,t]
center0(len : I, wid : I, fill : S) : RECLR ==
(wid < 1) or (len >= wid) => ["",""]$RECLR
m : I := (wid - len) quo 2
t : S := copies(1 + (m quo (sayLength fill)),fill)
[t(1..m),t(1..wid-len-m)]$RECLR
center(s, wid, fill) ==
wid < 1 => ""
len : I := sayLength s
len = wid => s
len > wid => s(1..wid)
rec : RECLR := center0(len,wid,fill)
concat [rec.lhs,s,rec.rhs]
center(l, wid, fill) ==
wid < 1 => [""]$(L S)
len : I := sayLength l
len = wid => l
-- len > wid => s(1..wid)
rec : RECLR := center0(len,wid,fill)
cons(rec.lhs,append(l,list rec.rhs))
say s ==
sayBrightly$Lisp s
say l ==
sayBrightly$Lisp l
sayLength s == #s
sayLength l ==
sum : I := 0
for s in l repeat
s = HION => sum := sum + 1
s = HIOFF => sum := sum + 1
s = NEWLINE => sum
sum := sum + sayLength s
sum
@
\section{License}
<<license>>=
--Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
--All rights reserved.
--
--Redistribution and use in source and binary forms, with or without
--modification, are permitted provided that the following conditions are
--met:
--
-- - Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
--
-- - Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in
-- the documentation and/or other materials provided with the
-- distribution.
--
-- - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-- names of its contributors may be used to endorse or promote products
-- derived from this software without specific prior written permission.
--
--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
--IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
--TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
--PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
--OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
--EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
--PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
--PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
--LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
--NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@
<<*>>=
<<license>>
<<package OUT OutputPackage>>
<<package SPECOUT SpecialOutputPackage>>
<<package DISPLAY DisplayPackage>>
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}
|