diff options
Diffstat (limited to 'src/algebra/outform.spad.pamphlet')
-rw-r--r-- | src/algebra/outform.spad.pamphlet | 339 |
1 files changed, 168 insertions, 171 deletions
diff --git a/src/algebra/outform.spad.pamphlet b/src/algebra/outform.spad.pamphlet index 00ca7d81..1c340f3e 100644 --- a/src/algebra/outform.spad.pamphlet +++ b/src/algebra/outform.spad.pamphlet @@ -225,250 +225,250 @@ import List OutputForm(): SetCategory with --% Printing - print : $ -> Void + print : % -> Void ++ print(u) prints the form u. - message: String -> $ + message: String -> % ++ message(s) creates an form with no string quotes ++ from string s. messagePrint: String -> Void ++ messagePrint(s) prints s without string quotes. Note: ++ \spad{messagePrint(s)} is equivalent to \spad{print message(s)}. --% Creation of atomic forms - outputForm: Integer -> $ + outputForm: Integer -> % ++ outputForm(n) creates an form for integer n. - outputForm: Symbol -> $ + outputForm: Symbol -> % ++ outputForm(s) creates an form for symbol s. - outputForm: String -> $ + outputForm: String -> % ++ outputForm(s) creates an form for string s. - outputForm: DoubleFloat -> $ + outputForm: DoubleFloat -> % ++ outputForm(sf) creates an form for small float sf. - empty : () -> $ + empty : () -> % ++ empty() creates an empty form. --% Sizings - width: $ -> Integer + width: % -> Integer ++ width(f) returns the width of form f (an integer). - height: $ -> Integer + height: % -> Integer ++ height(f) returns the height of form f (an integer). width: -> Integer ++ width() returns the width of the display area (an integer). height: -> Integer ++ height() returns the height of the display area (an integer). - subHeight: $ -> Integer + subHeight: % -> Integer ++ subHeight(f) returns the height of form f below the base line. - superHeight: $ -> Integer + superHeight: % -> Integer ++ superHeight(f) returns the height of form f above the base line. --% Space manipulations - hspace: Integer -> $ ++ hspace(n) creates white space of width n. - vspace: Integer -> $ ++ vspace(n) creates white space of height n. - rspace: (Integer,Integer) -> $ + hspace: Integer -> % ++ hspace(n) creates white space of width n. + vspace: Integer -> % ++ vspace(n) creates white space of height n. + rspace: (Integer,Integer) -> % ++ rspace(n,m) creates rectangular white space, n wide by m high. --% Area adjustments - left: ($,Integer) -> $ + left: (%,Integer) -> % ++ left(f,n) left-justifies form f within space of width n. - right: ($,Integer) -> $ + right: (%,Integer) -> % ++ right(f,n) right-justifies form f within space of width n. - center: ($,Integer) -> $ + center: (%,Integer) -> % ++ center(f,n) centers form f within space of width n. - left: $ -> $ + left: % -> % ++ left(f) left-justifies form f in total space. - right: $ -> $ + right: % -> % ++ right(f) right-justifies form f in total space. - center: $ -> $ + center: % -> % ++ center(f) centers form f in total space. --% Area manipulations - hconcat: ($,$) -> $ + hconcat: (%,%) -> % ++ hconcat(f,g) horizontally concatenate forms f and g. - vconcat: ($,$) -> $ + vconcat: (%,%) -> % ++ vconcat(f,g) vertically concatenates forms f and g. - hconcat: List $ -> $ + hconcat: List % -> % ++ hconcat(u) horizontally concatenates all forms in list u. - vconcat: List $ -> $ + vconcat: List % -> % ++ vconcat(u) vertically concatenates all forms in list u. --% Application formers - prefix: ($, List $) -> $ + prefix: (%, List %) -> % ++ prefix(f,l) creates a form depicting the n-ary prefix ++ application of f to a tuple of arguments given by list l. - infix: ($, List $) -> $ + infix: (%, List %) -> % ++ infix(f,l) creates a form depicting the n-ary application ++ of infix operation f to a tuple of arguments l. - infix: ($, $, $) -> $ + infix: (%, %, %) -> % ++ infix(op, a, b) creates a form which prints as: a op b. - postfix: ($, $) -> $ + postfix: (%, %) -> % ++ postfix(op, a) creates a form which prints as: a op. - infix?: $ -> Boolean + infix?: % -> Boolean ++ infix?(op) returns true if op is an infix operator, ++ and false otherwise. - elt: ($, List $) -> $ + elt: (%, List %) -> % ++ elt(op,l) creates a form for application of op ++ to list of arguments l. --% Special forms - string: $ -> $ + string: % -> % ++ string(f) creates f with string quotes. - label: ($, $) -> $ + label: (%, %) -> % ++ label(n,f) gives form f an equation label n. - box: $ -> $ + box: % -> % ++ box(f) encloses f in a box. - matrix: List List $ -> $ + matrix: List List % -> % ++ matrix(llf) makes llf (a list of lists of forms) into ++ a form which displays as a matrix. - zag: ($, $) -> $ + zag: (%, %) -> % ++ zag(f,g) creates a form for the continued fraction form for f over g. - root: $ -> $ + root: % -> % ++ root(f) creates a form for the square root of form f. - root: ($, $) -> $ + root: (%, %) -> % ++ root(f,n) creates a form for the nth root of form f. - over: ($, $) -> $ + over: (%, %) -> % ++ over(f,g) creates a form for the vertical fraction of f over g. - slash: ($, $) -> $ + slash: (%, %) -> % ++ slash(f,g) creates a form for the horizontal fraction of f over g. - assign: ($, $) -> $ + assign: (%, %) -> % ++ assign(f,g) creates a form for the assignment \spad{f := g}. - rarrow: ($, $) -> $ + rarrow: (%, %) -> % ++ rarrow(f,g) creates a form for the mapping \spad{f -> g}. - differentiate: ($, NonNegativeInteger) -> $ + differentiate: (%, NonNegativeInteger) -> % ++ differentiate(f,n) creates a form for the nth derivative of f, ++ e.g. \spad{f'}, \spad{f''}, \spad{f'''}, ++ "f super \spad{iv}". - binomial: ($, $) -> $ + binomial: (%, %) -> % ++ binomial(n,m) creates a form for the binomial coefficient of n and m. --% Scripts - sub: ($, $) -> $ + sub: (%, %) -> % ++ sub(f,n) creates a form for f subscripted by n. - super: ($, $) -> $ + super: (%, %) -> % ++ super(f,n) creates a form for f superscripted by n. - presub: ($, $) -> $ + presub: (%, %) -> % ++ presub(f,n) creates a form for f presubscripted by n. - presuper:($, $) -> $ + presuper:(%, %) -> % ++ presuper(f,n) creates a form for f presuperscripted by n. - scripts: ($, List $) -> $ + scripts: (%, List %) -> % ++ \spad{scripts(f, [sub, super, presuper, presub])} ++ creates a form for f with scripts on all 4 corners. - supersub:($, List $) -> $ + supersub:(%, List %) -> % ++ supersub(a,[sub1,super1,sub2,super2,...]) ++ creates a form with each subscript aligned ++ under each superscript. --% Diacritical marks - quote: $ -> $ + quote: % -> % ++ quote(f) creates the form f with a prefix quote. - dot: $ -> $ + dot: % -> % ++ dot(f) creates the form with a one dot overhead. - dot: ($, NonNegativeInteger) -> $ + dot: (%, NonNegativeInteger) -> % ++ dot(f,n) creates the form f with n dots overhead. - prime: $ -> $ + prime: % -> % ++ prime(f) creates the form f followed by a suffix prime (single quote). - prime: ($, NonNegativeInteger) -> $ + prime: (%, NonNegativeInteger) -> % ++ prime(f,n) creates the form f followed by n primes. - overbar: $ -> $ + overbar: % -> % ++ overbar(f) creates the form f with an overbar. - overlabel: ($, $) -> $ + overlabel: (%, %) -> % ++ overlabel(x,f) creates the form f with "x overbar" over the top. --% Plexes - sum: ($) -> $ + sum: (%) -> % ++ sum(expr) creates the form prefixing expr by a capital sigma. - sum: ($, $) -> $ + sum: (%, %) -> % ++ sum(expr,lowerlimit) creates the form prefixing expr by ++ a capital sigma with a lowerlimit. - sum: ($, $, $) -> $ + sum: (%, %, %) -> % ++ sum(expr,lowerlimit,upperlimit) creates the form prefixing expr by ++ a capital sigma with both a lowerlimit and upperlimit. - prod: ($) -> $ + prod: (%) -> % ++ prod(expr) creates the form prefixing expr by a capital pi. - prod: ($, $) -> $ + prod: (%, %) -> % ++ prod(expr,lowerlimit) creates the form prefixing expr by ++ a capital pi with a lowerlimit. - prod: ($, $, $) -> $ + prod: (%, %, %) -> % ++ prod(expr,lowerlimit,upperlimit) creates the form prefixing expr by ++ a capital pi with both a lowerlimit and upperlimit. - int: ($) -> $ + int: (%) -> % ++ int(expr) creates the form prefixing expr with an integral sign. - int: ($, $) -> $ + int: (%, %) -> % ++ int(expr,lowerlimit) creates the form prefixing expr by an ++ integral sign with a lowerlimit. - int: ($, $, $) -> $ + int: (%, %, %) -> % ++ int(expr,lowerlimit,upperlimit) creates the form prefixing expr by ++ an integral sign with both a lowerlimit and upperlimit. --% Matchfix forms - brace: $ -> $ + brace: % -> % ++ brace(f) creates the form enclosing f in braces (curly brackets). - brace: List $ -> $ + brace: List % -> % ++ brace(lf) creates the form separating the elements of lf ++ by commas and encloses the result in curly brackets. - bracket: $ -> $ + bracket: % -> % ++ bracket(f) creates the form enclosing f in square brackets. - bracket: List $ -> $ + bracket: List % -> % ++ bracket(lf) creates the form separating the elements of lf ++ by commas and encloses the result in square brackets. - paren: $ -> $ + paren: % -> % ++ paren(f) creates the form enclosing f in parentheses. - paren: List $ -> $ + paren: List % -> % ++ paren(lf) creates the form separating the elements of lf ++ by commas and encloses the result in parentheses. --% Separators for aggregates - pile: List $ -> $ + pile: List % -> % ++ pile(l) creates the form consisting of the elements of l which ++ displays as a pile, i.e. the elements begin on a new line and ++ are indented right to the same margin. - commaSeparate: List $ -> $ + commaSeparate: List % -> % ++ commaSeparate(l) creates the form separating the elements of l ++ by commas. - semicolonSeparate: List $ -> $ + semicolonSeparate: List % -> % ++ semicolonSeparate(l) creates the form separating the elements of l ++ by semicolons. - blankSeparate: List $ -> $ + blankSeparate: List % -> % ++ blankSeparate(l) creates the form separating the elements of l ++ by blanks. --% Specific applications - "=": ($, $) -> $ + "=": (%, %) -> % ++ f = g creates the equivalent infix form. - "~=": ($, $) -> $ + "~=": (%, %) -> % ++ f ~= g creates the equivalent infix form. - "<": ($, $) -> $ + "<": (%, %) -> % ++ f < g creates the equivalent infix form. - ">": ($, $) -> $ + ">": (%, %) -> % ++ f > g creates the equivalent infix form. - "<=": ($, $) -> $ + "<=": (%, %) -> % ++ f <= g creates the equivalent infix form. - ">=": ($, $) -> $ + ">=": (%, %) -> % ++ f >= g creates the equivalent infix form. - "+": ($, $) -> $ + "+": (%, %) -> % ++ f + g creates the equivalent infix form. - "-": ($, $) -> $ + "-": (%, %) -> % ++ f - g creates the equivalent infix form. - "-": ($) -> $ + "-": (%) -> % ++ - f creates the equivalent prefix form. - "*": ($, $) -> $ + "*": (%, %) -> % ++ f * g creates the equivalent infix form. - "/": ($, $) -> $ + "/": (%, %) -> % ++ f / g creates the equivalent infix form. - "**": ($, $) -> $ + "**": (%, %) -> % ++ f ** g creates the equivalent infix form. - "div": ($, $) -> $ + "div": (%, %) -> % ++ f div g creates the equivalent infix form. - "rem": ($, $) -> $ + "rem": (%, %) -> % ++ f rem g creates the equivalent infix form. - "quo": ($, $) -> $ + "quo": (%, %) -> % ++ f quo g creates the equivalent infix form. - "exquo": ($, $) -> $ + "exquo": (%, %) -> % ++ exquo(f,g) creates the equivalent infix form. - "and": ($, $) -> $ + "and": (%, %) -> % ++ f and g creates the equivalent infix form. - "or": ($, $) -> $ + "or": (%, %) -> % ++ f or g creates the equivalent infix form. - "not": ($) -> $ + "not": (%) -> % ++ not f creates the equivalent prefix form. - SEGMENT: ($,$) -> $ + SEGMENT: (%,%) -> % ++ SEGMENT(x,y) creates the infix form: \spad{x..y}. - SEGMENT: ($) -> $ + SEGMENT: (%) -> % ++ SEGMENT(x) creates the prefix form: \spad{x..}. == add @@ -486,31 +486,28 @@ OutputForm(): SetCategory with car ==> CAR$Lisp cdr ==> CDR$Lisp - Rep := List $ - - a, b: $ - l: List $ + a, b: % + l: List % s: String e: Symbol n: Integer nn:NonNegativeInteger - sform: String -> $ - eform: Symbol -> $ - iform: Integer -> $ + sform(s: String): % == s pretend % + eform(e: Symbol): % == e pretend % + iform(i: Integer): % == i pretend % + + bless(x: List %): % == x pretend % print x == mathprint(x)$Lisp - message s == (empty? s => empty(); s pretend $) + message s == (empty? s => empty(); s pretend %) messagePrint s == print message s - (a:$ = b:$):Boolean == EQUAL(a, b)$Lisp - (a:$ = b:$):$ == [sform "=", a, b] + (a:% = b:%): Boolean == EQUAL(a, b)$Lisp + (a:% = b:%):% == bless [sform "=", a, b] coerce(a):OutputForm == a pretend OutputForm - outputForm n == n pretend $ - outputForm e == e pretend $ - outputForm(f:DoubleFloat) == f pretend $ - sform s == s pretend $ - eform e == e pretend $ - iform n == n pretend $ + outputForm n == n pretend % + outputForm e == e pretend % + outputForm(f:DoubleFloat) == f pretend % outputForm s == sform concat(quote()$Character, concat(s, quote()$Character)) @@ -542,7 +539,7 @@ OutputForm(): SetCategory with vconcat(hspace n, rspace(n, m - 1)) matrix ll == - lv:$ := [LIST2VEC$Lisp l for l in ll] + lv := bless [LIST2VEC$Lisp l for l in ll] CONS(eform MATRIX, LIST2VEC$Lisp lv)$Lisp pile l == cons(eform SC, l) @@ -550,24 +547,24 @@ OutputForm(): SetCategory with semicolonSeparate l == cons(eform AGGSET, l) blankSeparate l == c:=eform CONCATB - l1:$:=[] + l1: List % :=[] for u in reverse l repeat if EQCAR(u,c)$Lisp then l1:=[:cdr u,:l1] else l1:=[u,:l1] cons(c, l1) - brace a == [eform BRACE, a] + brace a == bless [eform BRACE, a] brace l == brace commaSeparate l - bracket a == [eform BRACKET, a] + bracket a == bless [eform BRACKET, a] bracket l == bracket commaSeparate l - paren a == [eform PAREN, a] + paren a == bless [eform PAREN, a] paren l == paren commaSeparate l - sub (a,b) == [eform SUB, a, b] - super (a, b) == [eform SUPERSUB,a,sform " ",b] - presub(a,b) == [eform SUPERSUB,a,sform " ",sform " ",sform " ",b] - presuper(a, b) == [eform SUPERSUB,a,sform " ",sform " ",b] + sub (a,b) == bless [eform SUB, a, b] + super (a, b) == bless [eform SUPERSUB,a,sform " ",b] + presub(a,b) == bless [eform SUPERSUB,a,sform " ",sform " ",sform " ",b] + presuper(a, b) == bless [eform SUPERSUB,a,sform " ",sform " ",b] scripts (a, l) == null l => a null rest l => sub(a, first l) @@ -576,35 +573,35 @@ OutputForm(): SetCategory with if odd?(#l) then l := append(l, [empty()]) cons(eform ALTSUPERSUB, cons(a, l)) - hconcat(a,b) == [eform CONCAT, a, b] + hconcat(a,b) == bless [eform CONCAT, a, b] hconcat l == cons(eform CONCAT, l) - vconcat(a,b) == [eform VCONCAT, a, b] + vconcat(a,b) == bless [eform VCONCAT, a, b] vconcat l == cons(eform VCONCAT, l) - (a:% ~= b:%): % == [sform "~=", a, b] - a < b == [sform "<", a, b] - a > b == [sform ">", a, b] - a <= b == [sform "<=", a, b] - a >= b == [sform ">=", a, b] - - a + b == [sform "+", a, b] - a - b == [sform "-", a, b] - - a == [sform "-", a] - a * b == [sform "*", a, b] - a / b == [sform "/", a, b] - a ** b == [sform "**", a, b] - a div b == [sform "div", a, b] - a rem b == [sform "rem", a, b] - a quo b == [sform "quo", a, b] - a exquo b == [sform "exquo", a, b] - a and b == [sform "and", a, b] - a or b == [sform "or", a, b] - not a == [sform "not", a] - SEGMENT(a,b)== [eform SEGMENT, a, b] - SEGMENT(a) == [eform SEGMENT, a] - binomial(a,b)==[eform BINOMIAL, a, b] - - empty() == [eform NOTHING] + (a:% ~= b:%): % == bless [sform "~=", a, b] + a < b == bless [sform "<", a, b] + a > b == bless [sform ">", a, b] + a <= b == bless [sform "<=", a, b] + a >= b == bless [sform ">=", a, b] + + a + b == bless [sform "+", a, b] + a - b == bless [sform "-", a, b] + - a == bless [sform "-", a] + a * b == bless [sform "*", a, b] + a / b == bless [sform "/", a, b] + a ** b == bless [sform "**", a, b] + a div b == bless [sform "div", a, b] + a rem b == bless [sform "rem", a, b] + a quo b == bless [sform "quo", a, b] + a exquo b == bless [sform "exquo", a, b] + a and b == bless [sform "and", a, b] + a or b == bless [sform "or", a, b] + not a == bless [sform "not", a] + SEGMENT(a,b)== bless [eform SEGMENT, a, b] + SEGMENT(a) == bless [eform SEGMENT, a] + binomial(a,b)== bless [eform BINOMIAL, a, b] + + empty() == bless [eform NOTHING] infix? a == e:$ := @@ -624,30 +621,30 @@ OutputForm(): SetCategory with infix? a => cons(a, l) hconcat [first l, a, infix(a, rest l)] infix(a,b,c) == - infix? a => [a, b, c] + infix? a => bless [a, b, c] hconcat [b, a, c] postfix(a, b) == hconcat(b, a) - string a == [eform STRING, a] - quote a == [eform QUOTE, a] - overbar a == [eform OVERBAR, a] + string a == bless [eform STRING, a] + quote a == bless [eform QUOTE, a] + overbar a == bless [eform OVERBAR, a] dot a == super(a, sform ".") prime a == super(a, sform ",") dot(a,nn) == (s := new(nn, char "."); super(a, sform s)) prime(a,nn) == (s := new(nn, char ","); super(a, sform s)) - overlabel(a,b) == [eform OVERLABEL, a, b] - box a == [eform BOX, a] - zag(a,b) == [eform ZAG, a, b] - root a == [eform ROOT, a] - root(a,b) == [eform ROOT, a, b] - over(a,b) == [eform OVER, a, b] - slash(a,b) == [eform SLASH, a, b] - assign(a,b)== [eform LET, a, b] - - label(a,b) == [eform EQUATNUM, a, b] - rarrow(a,b)== [eform TAG, a, b] + overlabel(a,b) == bless [eform OVERLABEL, a, b] + box a == bless [eform BOX, a] + zag(a,b) == bless [eform ZAG, a, b] + root a == bless [eform ROOT, a] + root(a,b) == bless [eform ROOT, a, b] + over(a,b) == bless [eform OVER, a, b] + slash(a,b) == bless [eform SLASH, a, b] + assign(a,b)== bless [eform LET, a, b] + + label(a,b) == bless [eform EQUATNUM, a, b] + rarrow(a,b)== bless [eform TAG, a, b] differentiate(a, nn)== zero? nn => a nn < 4 => prime(a, nn) @@ -655,15 +652,15 @@ OutputForm(): SetCategory with s := lowerCase(r::String) super(a, paren sform s) - sum(a) == [eform SIGMA, empty(), a] - sum(a,b) == [eform SIGMA, b, a] - sum(a,b,c) == [eform SIGMA2, b, c, a] - prod(a) == [eform PI, empty(), a] - prod(a,b) == [eform PI, b, a] - prod(a,b,c)== [eform PI2, b, c, a] - int(a) == [eform INTSIGN,empty(), empty(), a] - int(a,b) == [eform INTSIGN,b, empty(), a] - int(a,b,c) == [eform INTSIGN,b, c, a] + sum(a) == bless [eform SIGMA, empty(), a] + sum(a,b) == bless [eform SIGMA, b, a] + sum(a,b,c) == bless [eform SIGMA2, b, c, a] + prod(a) == bless [eform PI, empty(), a] + prod(a,b) == bless [eform PI, b, a] + prod(a,b,c)== bless [eform PI2, b, c, a] + int(a) == bless [eform INTSIGN,empty(), empty(), a] + int(a,b) == bless [eform INTSIGN,b, empty(), a] + int(a,b,c) == bless [eform INTSIGN,b, c, a] @ |