[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] 20080824.01.tpd.patch (use ++X for examples lines)
From: |
daly |
Subject: |
[Axiom-developer] 20080824.01.tpd.patch (use ++X for examples lines) |
Date: |
Mon, 25 Aug 2008 20:38:22 -0500 |
This change makes the syntax of regression tests and the syntax of
example tests equal. The ++(letter) and --(letter) will have the
same meaning. An upcoming change will automate testing functions which
are exposed in the algebra API, making the user examples serve a dual
purpose and providing better regression coverage of the algebra.
So far, the assigned letters mean:
C -- command line, not part of the test
E -- end of test block
R -- result line to compare against the actual result
S -- start of the text block
X -- example line from algebra
Use ++X for example lines. Reserve ++E to mark the end of the regression
test block.
=======================================================================
diff --git a/changelog b/changelog
index 43b1f80..e2cd290 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,20 @@
+20080824 tpd src/interp/format.boot use ++X
+20080824 tpd src/algebra/tree.spad use ++X
+20080824 tpd src/algebra/string.spad use ++X
+20080824 tpd src/algebra/stream.spad use ++X
+20080824 tpd src/algebra/radix.spad use ++X
+20080824 tpd src/algebra/plot.spad use ++X
+20080824 tpd src/algebra/mkfunc.spad use ++X
+20080824 tpd src/algebra/mappkg.spad use ++X
+20080824 tpd src/algebra/listgcd.spad use ++X
+20080824 tpd src/algebra/fr.spad use ++X
+20080824 tpd src/algebra/curve.spad use ++X
+20080824 tpd src/algebra/carten.spad use ++X
+20080824 tpd src/algebra/card.spad use ++X
+20080824 tpd src/algebra/bags.spad use ++X
+20080824 tpd src/algebra/array2.spad use ++X
+20080824 tpd src/algebra/array1.spad use ++X
+20080824 tpd src/algebra/aggcat.spad use ++X
20080823 tpd src/algebra/s.spad remove ++CapitalLetter syntax
20080823 tpd src/algebra/multsqfr.spad remove ++CapitalLetter syntax
20080823 tpd src/algebra/f07.spad remove ++CapitalLetter syntax
diff --git a/src/algebra/aggcat.spad.pamphlet b/src/algebra/aggcat.spad.pamphlet
index 69b8371..ee39ddd 100644
--- a/src/algebra/aggcat.spad.pamphlet
+++ b/src/algebra/aggcat.spad.pamphlet
@@ -1220,9 +1220,9 @@ TableAggregate(Key:SetCategory, Entry:SetCategory):
Category ==
table: () -> %
++ table()$T creates an empty table of type T.
++
- ++E Data:=Record(age:Integer,gender:String)
- ++E a1:AssociationList(String,Data):=table()
- ++E a1."tim":=[55,"male"]$Data
+ ++X Data:=Record(age:Integer,gender:String)
+ ++X a1:AssociationList(String,Data):=table()
+ ++X a1."tim":=[55,"male"]$Data
table: List Record(key:Key,entry:Entry) -> %
++ table([x,y,...,z]) creates a table consisting of entries
@@ -1623,8 +1623,8 @@ UnaryRecursiveAggregate(S:Type): Category ==
RecursiveAggregate S with
++ followed by the elements of v.
++ Note: \axiom{v = rest(w,#a)}.
++
- ++E m:=[1,2,3]
- ++E concat(5,m)
+ ++X m:=[1,2,3]
+ ++X concat(5,m)
concat: (S,%) -> %
++ concat(x,u) returns aggregate consisting of x followed by
@@ -1632,15 +1632,15 @@ UnaryRecursiveAggregate(S:Type): Category ==
RecursiveAggregate S with
++ Note: if \axiom{v = concat(x,u)} then \axiom{x = first v}
++ and \axiom{u = rest v}.
++
- ++E m:=[1,2,3]
- ++E concat(m,m)
+ ++X m:=[1,2,3]
+ ++X concat(m,m)
first: % -> S
++ first(u) returns the first element of u
++ (equivalently, the value at the current node).
++
- ++E m:=[1,2,3]
- ++E first(m)
+ ++X m:=[1,2,3]
+ ++X first(m)
elt: (%,"first") -> S
++ elt(u,"first") (also written: \axiom{u . first}) is
@@ -1650,16 +1650,16 @@ UnaryRecursiveAggregate(S:Type): Category ==
RecursiveAggregate S with
++ first(u,n) returns a copy of the first n
++ (\axiom{n >= 0}) elements of u.
++
- ++E m:=[1,2,3]
- ++E first(m,2)
+ ++X m:=[1,2,3]
+ ++X first(m,2)
rest: % -> %
++ rest(u) returns an aggregate consisting of all but the first
++ element of u
++ (equivalently, the next node of u).
++
- ++E m:=[1,2,3]
- ++E rest m
+ ++X m:=[1,2,3]
+ ++X rest m
elt: (%,"rest") -> %
++ elt(%,"rest") (also written: \axiom{u.rest}) is
@@ -1669,15 +1669,15 @@ UnaryRecursiveAggregate(S:Type): Category ==
RecursiveAggregate S with
++ rest(u,n) returns the \axiom{n}th (n >= 0) node of u.
++ Note: \axiom{rest(u,0) = u}.
++
- ++E m:=[1,2,3]
- ++E rest(m,2)
+ ++X m:=[1,2,3]
+ ++X rest(m,2)
last: % -> S
++ last(u) resturn the last element of u.
++ Note: for lists, \axiom{last(u) = u . (maxIndex u) = u . (# u - 1)}.
++
- ++E m:=[1,2,3]
- ++E last m
+ ++X m:=[1,2,3]
+ ++X last m
elt: (%,"last") -> S
++ elt(u,"last") (also written: \axiom{u . last}) is equivalent to last u.
@@ -1686,70 +1686,70 @@ UnaryRecursiveAggregate(S:Type): Category ==
RecursiveAggregate S with
++ last(u,n) returns a copy of the last n (\axiom{n >= 0}) nodes of u.
++ Note: \axiom{last(u,n)} is a list of n elements.
++
- ++E m:=[1,2,3]
- ++E last(m,2)
+ ++X m:=[1,2,3]
+ ++X last(m,2)
tail: % -> %
++ tail(u) returns the last node of u.
++ Note: if u is \axiom{shallowlyMutable},
++ \axiom{setrest(tail(u),v) = concat(u,v)}.
++
- ++E m:=[1,2,3]
- ++E last(m,2)
+ ++X m:=[1,2,3]
+ ++X last(m,2)
second: % -> S
++ second(u) returns the second element of u.
++ Note: \axiom{second(u) = first(rest(u))}.
++
- ++E m:=[1,2,3]
- ++E second m
+ ++X m:=[1,2,3]
+ ++X second m
third: % -> S
++ third(u) returns the third element of u.
++ Note: \axiom{third(u) = first(rest(rest(u)))}.
++
- ++E m:=[1,2,3]
- ++E third m
+ ++X m:=[1,2,3]
+ ++X third m
cycleEntry: % -> %
++ cycleEntry(u) returns the head of a top-level cycle contained in
++ aggregate u, or \axiom{empty()} if none exists.
++
- ++E m:=[1,2,3]
- ++E concat!(m,tail(m))
- ++E cycleEntry m
+ ++X m:=[1,2,3]
+ ++X concat!(m,tail(m))
+ ++X cycleEntry m
cycleLength: % -> NonNegativeInteger
++ cycleLength(u) returns the length of a top-level cycle
++ contained in aggregate u, or 0 is u has no such cycle.
++
- ++E m:=[1,2,3]
- ++E concat!(m,tail(m))
- ++E cycleLength m
+ ++X m:=[1,2,3]
+ ++X concat!(m,tail(m))
+ ++X cycleLength m
cycleTail: % -> %
++ cycleTail(u) returns the last node in the cycle, or
++ empty if none exists.
++
- ++E m:=[1,2,3]
- ++E concat!(m,tail(m))
- ++E cycleTail m
+ ++X m:=[1,2,3]
+ ++X concat!(m,tail(m))
+ ++X cycleTail m
if % has shallowlyMutable then
concat_!: (%,%) -> %
++ concat!(u,v) destructively concatenates v to the end of u.
++ Note: \axiom{concat!(u,v) = setlast_!(u,v)}.
++
- ++E m:=[1,2,3]
- ++E n:=[4,5,6]
- ++E concat!(m,n)
+ ++X m:=[1,2,3]
+ ++X n:=[4,5,6]
+ ++X concat!(m,n)
concat_!: (%,S) -> %
++ concat!(u,x) destructively adds element x to the end of u.
++ Note: \axiom{concat!(a,x) = setlast!(a,[x])}.
++
- ++E m:=[1,2,3]
- ++E concat!(m,5)
+ ++X m:=[1,2,3]
+ ++X concat!(m,5)
cycleSplit_!: % -> %
++ cycleSplit!(u) splits the aggregate by dropping off the cycle.
@@ -1758,20 +1758,20 @@ UnaryRecursiveAggregate(S:Type): Category ==
RecursiveAggregate S with
++ the head of the cycle, \axiom{cycleSplit!(w)} will drop v off w thus
++ destructively changing w to u, and returning v.
++
- ++E m:=[1,2,3]
- ++E concat!(m,m)
- ++E n:=[4,5,6]
- ++E p:=concat(n,m)
- ++E q:=cycleSplit! p
- ++E p
- ++E q
+ ++X m:=[1,2,3]
+ ++X concat!(m,m)
+ ++X n:=[4,5,6]
+ ++X p:=concat(n,m)
+ ++X q:=cycleSplit! p
+ ++X p
+ ++X q
setfirst_!: (%,S) -> S
++ setfirst!(u,x) destructively changes the first element of a to x.
++
- ++E m:=[1,2,3]
- ++E setfirst!(m,4)
- ++E m
+ ++X m:=[1,2,3]
+ ++X setfirst!(m,4)
+ ++X m
setelt: (%,"first",S) -> S
++ setelt(u,"first",x) (also written: \axiom{u.first := x}) is
@@ -1780,9 +1780,9 @@ UnaryRecursiveAggregate(S:Type): Category ==
RecursiveAggregate S with
setrest_!: (%,%) -> %
++ setrest!(u,v) destructively changes the rest of u to v.
++
- ++E m:=[1,2,3]
- ++E setrest!(m,[4,5,6])
- ++E m
+ ++X m:=[1,2,3]
+ ++X setrest!(m,[4,5,6])
+ ++X m
setelt: (%,"rest",%) -> %
++ setelt(u,"rest",v) (also written: \axiom{u.rest := v})
@@ -1791,9 +1791,9 @@ UnaryRecursiveAggregate(S:Type): Category ==
RecursiveAggregate S with
setlast_!: (%,S) -> S
++ setlast!(u,x) destructively changes the last element of u to x.
++
- ++E m:=[1,2,3]
- ++E setlast!(m,4)
- ++E m
+ ++X m:=[1,2,3]
+ ++X setlast!(m,4)
+ ++X m
setelt: (%,"last",S) -> S
++ setelt(u,"last",x) (also written: \axiom{u.last := b})
@@ -1804,10 +1804,10 @@ UnaryRecursiveAggregate(S:Type): Category ==
RecursiveAggregate S with
++ and \axiom{w = first(u,n)}, returning \axiom{v}.
++ Note: afterwards \axiom{rest(u,n)} returns \axiom{empty()}.
++
- ++E m:=[1,2,3,4]
- ++E n:=split!(m,2)
- ++E m
- ++E n
+ ++X m:=[1,2,3,4]
+ ++X n:=split!(m,2)
+ ++X m
+ ++X n
add
cycleMax ==> 1000
@@ -2717,10 +2717,10 @@ ExtensibleLinearAggregate(S:Type):Category ==
LinearAggregate S with
delete_!: (%,Integer) -> %
++ delete!(u,i) destructively deletes the \axiom{i}th element of u.
++
- ++E Data:=Record(age:Integer,gender:String)
- ++E a1:AssociationList(String,Data):=table()
- ++E a1."tim":=[55,"male"]$Data
- ++E delete!(a1,1)
+ ++X Data:=Record(age:Integer,gender:String)
+ ++X a1:AssociationList(String,Data):=table()
+ ++X a1."tim":=[55,"male"]$Data
+ ++X delete!(a1,1)
delete_!: (%,UniversalSegment(Integer)) -> %
++ delete!(u,i..j) destructively deletes elements u.i through u.j.
diff --git a/src/algebra/array1.spad.pamphlet b/src/algebra/array1.spad.pamphlet
index b4adc3d..7f4be27 100644
--- a/src/algebra/array1.spad.pamphlet
+++ b/src/algebra/array1.spad.pamphlet
@@ -232,9 +232,9 @@ PrimitiveArrayFunctions2(A, B): Exports == Implementation
where
++ \spad{scan(f,a,r)} returns
++ \spad{[reduce(f,[a1],r),reduce(f,[a1,a2],r),...]}.
++
- ++E T1:=PrimitiveArrayFunctions2(Integer,Integer)
- ++E adder(a:Integer,b:Integer):Integer == a+b
- ++E scan(adder,[i for i in 1..10],0)$T1
+ ++X T1:=PrimitiveArrayFunctions2(Integer,Integer)
+ ++X adder(a:Integer,b:Integer):Integer == a+b
+ ++X scan(adder,[i for i in 1..10],0)$T1
reduce : ((A, B) -> B, VA, B) -> B
++ reduce(f,a,r) applies function f to each
@@ -244,17 +244,17 @@ PrimitiveArrayFunctions2(A, B): Exports == Implementation
where
++ does \spad{3+(2+(1+0))}. Note: third argument r
++ may be regarded as the identity element for the function f.
++
- ++E T1:=PrimitiveArrayFunctions2(Integer,Integer)
- ++E adder(a:Integer,b:Integer):Integer == a+b
- ++E reduce(adder,[i for i in 1..10],0)$T1
+ ++X T1:=PrimitiveArrayFunctions2(Integer,Integer)
+ ++X adder(a:Integer,b:Integer):Integer == a+b
+ ++X reduce(adder,[i for i in 1..10],0)$T1
map : (A -> B, VA) -> VB
++ map(f,a) applies function f to each member of primitive array
++ \spad{a} resulting in a new primitive array over a
++ possibly different underlying domain.
++
- ++E T1:=PrimitiveArrayFunctions2(Integer,Integer)
- ++E map(x+->x+2,[i for i in 1..10])$T1
+ ++X T1:=PrimitiveArrayFunctions2(Integer,Integer)
+ ++X map(x+->x+2,[i for i in 1..10])$T1
Implementation ==> add
map(f, v) == map(f, v)$O2
@@ -271,23 +271,23 @@ Tuple(S:Type): CoercibleTo(PrimitiveArray S) with
coerce: PrimitiveArray S -> %
++ coerce(a) makes a tuple from primitive array a
++
- ++E t1:PrimitiveArray(Integer):= [i for i in 1..10]
- ++E t2:=coerce(t1)$Tuple(Integer)
+ ++X t1:PrimitiveArray(Integer):= [i for i in 1..10]
+ ++X t2:=coerce(t1)$Tuple(Integer)
select: (%, NonNegativeInteger) -> S
++ select(x,n) returns the n-th element of tuple x.
++ tuples are 0-based
++
- ++E t1:PrimitiveArray(Integer):= [i for i in 1..10]
- ++E t2:=coerce(t1)$Tuple(Integer)
- ++E select(t2,3)
+ ++X t1:PrimitiveArray(Integer):= [i for i in 1..10]
+ ++X t2:=coerce(t1)$Tuple(Integer)
+ ++X select(t2,3)
length: % -> NonNegativeInteger
++ length(x) returns the number of elements in tuple x
++
- ++E t1:PrimitiveArray(Integer):= [i for i in 1..10]
- ++E t2:=coerce(t1)$Tuple(Integer)
- ++E length(t2)
+ ++X t1:PrimitiveArray(Integer):= [i for i in 1..10]
+ ++X t2:=coerce(t1)$Tuple(Integer)
+ ++X length(t2)
if S has SetCategory then SetCategory
== add
@@ -337,31 +337,31 @@ IndexedFlexibleArray(S:Type, mn: Integer): Exports ==
Implementation where
flexibleArray : List S -> %
++ flexibleArray(l) creates a flexible array from the list of elements l
++
- ++E T1:=IndexedFlexibleArray(Integer,20)
- ++E flexibleArray([i for i in 1..10])$T1
+ ++X T1:=IndexedFlexibleArray(Integer,20)
+ ++X flexibleArray([i for i in 1..10])$T1
physicalLength : % -> NonNegativeInteger
++ physicalLength(x) returns the number of elements x can
++ accomodate before growing
++
- ++E T1:=IndexedFlexibleArray(Integer,20)
- ++E t2:=flexibleArray([i for i in 1..10])$T1
- ++E physicalLength t2
+ ++X T1:=IndexedFlexibleArray(Integer,20)
+ ++X t2:=flexibleArray([i for i in 1..10])$T1
+ ++X physicalLength t2
physicalLength_!: (%, I) -> %
++ physicalLength!(x,n) changes the physical length of x to be n and
++ returns the new array.
++
- ++E T1:=IndexedFlexibleArray(Integer,20)
- ++E t2:=flexibleArray([i for i in 1..10])$T1
- ++E physicalLength!(t2,15)
+ ++X T1:=IndexedFlexibleArray(Integer,20)
+ ++X t2:=flexibleArray([i for i in 1..10])$T1
+ ++X physicalLength!(t2,15)
shrinkable: Boolean -> Boolean
++ shrinkable(b) sets the shrinkable attribute of flexible arrays to b
++ and returns the previous value
++
- ++E T1:=IndexedFlexibleArray(Integer,20)
- ++E shrinkable(false)$T1
+ ++X T1:=IndexedFlexibleArray(Integer,20)
+ ++X shrinkable(false)$T1
Implementation == add
Rep := Record(physLen:I, logLen:I, f:A)
@@ -1087,12 +1087,12 @@ OneDimensionalArray(S:Type): Exports == Implementation
where
oneDimensionalArray: List S -> %
++ oneDimensionalArray(l) creates an array from a list of elements l
++
- ++E oneDimensionalArray [i**2 for i in 1..10]
+ ++X oneDimensionalArray [i**2 for i in 1..10]
oneDimensionalArray: (NonNegativeInteger, S) -> %
++ oneDimensionalArray(n,s) creates an array from n copies of element s
++
- ++E oneDimensionalArray(10,0.0)
+ ++X oneDimensionalArray(10,0.0)
Implementation == IndexedOneDimensionalArray(S, ARRAYMININDEX) add
oneDimensionalArray(u) ==
@@ -1125,9 +1125,9 @@ OneDimensionalArrayFunctions2(A, B): Exports ==
Implementation where
++ \spad{scan(f,a,r)} returns
++ \spad{[reduce(f,[a1],r),reduce(f,[a1,a2],r),...]}.
++
- ++E T1:=OneDimensionalArrayFunctions2(Integer,Integer)
- ++E adder(a:Integer,b:Integer):Integer == a+b
- ++E scan(adder,[i for i in 1..10],0)$T1
+ ++X T1:=OneDimensionalArrayFunctions2(Integer,Integer)
+ ++X adder(a:Integer,b:Integer):Integer == a+b
+ ++X scan(adder,[i for i in 1..10],0)$T1
reduce : ((A, B) -> B, VA, B) -> B
++ reduce(f,a,r) applies function f to each
@@ -1137,17 +1137,17 @@ OneDimensionalArrayFunctions2(A, B): Exports ==
Implementation where
++ does \spad{3+(2+(1+0))}. Note: third argument r
++ may be regarded as the identity element for the function f.
++
- ++E T1:=OneDimensionalArrayFunctions2(Integer,Integer)
- ++E adder(a:Integer,b:Integer):Integer == a+b
- ++E reduce(adder,[i for i in 1..10],0)$T1
+ ++X T1:=OneDimensionalArrayFunctions2(Integer,Integer)
+ ++X adder(a:Integer,b:Integer):Integer == a+b
+ ++X reduce(adder,[i for i in 1..10],0)$T1
map : (A -> B, VA) -> VB
++ map(f,a) applies function f to each member of one-dimensional array
++ \spad{a} resulting in a new one-dimensional array over a
++ possibly different underlying domain.
++
- ++E T1:=OneDimensionalArrayFunctions2(Integer,Integer)
- ++E map(x+->x+2,[i for i in 1..10])$T1
+ ++X T1:=OneDimensionalArrayFunctions2(Integer,Integer)
+ ++X map(x+->x+2,[i for i in 1..10])$T1
Implementation ==> add
map(f, v) == map(f, v)$O2
diff --git a/src/algebra/array2.spad.pamphlet b/src/algebra/array2.spad.pamphlet
index e6a8b7a..a6f9cd7 100644
--- a/src/algebra/array2.spad.pamphlet
+++ b/src/algebra/array2.spad.pamphlet
@@ -46,51 +46,51 @@ TwoDimensionalArrayCategory(R,Row,Col): Category ==
Definition where
new: (NonNegativeInteger,NonNegativeInteger,R) -> %
++ new(m,n,r) is an m-by-n array all of whose entries are r
++
- ++E arr : ARRAY2 INT := new(5,4,0)
+ ++X arr : ARRAY2 INT := new(5,4,0)
fill_!: (%,R) -> %
++ fill!(m,r) fills m with r's
++
- ++E arr : ARRAY2 INT := new(5,4,0)
- ++E fill!(arr,10)
+ ++X arr : ARRAY2 INT := new(5,4,0)
+ ++X fill!(arr,10)
--% Size inquiries
minRowIndex : % -> Integer
++ minRowIndex(m) returns the index of the 'first' row of the array m
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E minRowIndex(arr)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X minRowIndex(arr)
maxRowIndex : % -> Integer
++ maxRowIndex(m) returns the index of the 'last' row of the array m
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E maxRowIndex(arr)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X maxRowIndex(arr)
minColIndex : % -> Integer
++ minColIndex(m) returns the index of the 'first' column of the array m
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E minColIndex(arr)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X minColIndex(arr)
maxColIndex : % -> Integer
++ maxColIndex(m) returns the index of the 'last' column of the array m
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E maxColIndex(arr)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X maxColIndex(arr)
nrows : % -> NonNegativeInteger
++ nrows(m) returns the number of rows in the array m
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E nrows(arr)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X nrows(arr)
ncols : % -> NonNegativeInteger
++ ncols(m) returns the number of columns in the array m
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E ncols(arr)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X ncols(arr)
--% Part extractions
@@ -99,45 +99,45 @@ TwoDimensionalArrayCategory(R,Row,Col): Category ==
Definition where
++ column of the array m
++ error check to determine if indices are in proper ranges
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E elt(arr,1,1)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X elt(arr,1,1)
qelt: (%,Integer,Integer) -> R
++ qelt(m,i,j) returns the element in the ith row and jth
++ column of the array m
++ NO error check to determine if indices are in proper ranges
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E qelt(arr,1,1)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X qelt(arr,1,1)
elt: (%,Integer,Integer,R) -> R
++ elt(m,i,j,r) returns the element in the ith row and jth
++ column of the array m, if m has an ith row and a jth column,
++ and returns r otherwise
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E elt(arr,1,1,6)
- ++E elt(arr,1,10,6)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X elt(arr,1,1,6)
+ ++X elt(arr,1,10,6)
row: (%,Integer) -> Row
++ row(m,i) returns the ith row of m
++ error check to determine if index is in proper ranges
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E row(arr,1)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X row(arr,1)
column: (%,Integer) -> Col
++ column(m,j) returns the jth column of m
++ error check to determine if index is in proper ranges
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E column(arr,1)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X column(arr,1)
parts: % -> List R
++ parts(m) returns a list of the elements of m in row major order
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E parts(arr)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X parts(arr)
--% Part assignments
@@ -147,34 +147,34 @@ TwoDimensionalArrayCategory(R,Row,Col): Category ==
Definition where
++ column of m to r
++ error check to determine if indices are in proper ranges
++
- ++E arr : ARRAY2 INT := new(5,4,0)
- ++E setelt(arr,1,1,17)
+ ++X arr : ARRAY2 INT := new(5,4,0)
+ ++X setelt(arr,1,1,17)
qsetelt_!: (%,Integer,Integer,R) -> R
++ qsetelt!(m,i,j,r) sets the element in the ith row and jth
++ column of m to r
++ NO error check to determine if indices are in proper ranges
++
- ++E arr : ARRAY2 INT := new(5,4,0)
- ++E qsetelt!(arr,1,1,17)
+ ++X arr : ARRAY2 INT := new(5,4,0)
+ ++X qsetelt!(arr,1,1,17)
setRow_!: (%,Integer,Row) -> %
++ setRow!(m,i,v) sets to ith row of m to v
++
- ++E T1:=TwoDimensionalArray Integer
- ++E arr:T1:= new(5,4,0)
- ++E T2:=OneDimensionalArray Integer
- ++E arow:=construct([1,2,3,4]::List(INT))$T2
- ++E setRow!(arr,1,arow)$T1
+ ++X T1:=TwoDimensionalArray Integer
+ ++X arr:T1:= new(5,4,0)
+ ++X T2:=OneDimensionalArray Integer
+ ++X arow:=construct([1,2,3,4]::List(INT))$T2
+ ++X setRow!(arr,1,arow)$T1
setColumn_!: (%,Integer,Col) -> %
++ setColumn!(m,j,v) sets to jth column of m to v
++
- ++E T1:=TwoDimensionalArray Integer
- ++E arr:T1:= new(5,4,0)
- ++E T2:=OneDimensionalArray Integer
- ++E acol:=construct([1,2,3,4,5]::List(INT))$T2
- ++E setColumn!(arr,1,acol)$T1
+ ++X T1:=TwoDimensionalArray Integer
+ ++X arr:T1:= new(5,4,0)
+ ++X T2:=OneDimensionalArray Integer
+ ++X acol:=construct([1,2,3,4,5]::List(INT))$T2
+ ++X setColumn!(arr,1,acol)$T1
--% Map and Zip
@@ -182,23 +182,23 @@ TwoDimensionalArrayCategory(R,Row,Col): Category ==
Definition where
++ map(f,a) returns \spad{b}, where \spad{b(i,j) = f(a(i,j))}
++ for all \spad{i, j}
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E map(-,arr)
- ++E map((x +-> x + x),arr)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X map(-,arr)
+ ++X map((x +-> x + x),arr)
map_!: (R -> R,%) -> %
++ map!(f,a) assign \spad{a(i,j)} to \spad{f(a(i,j))} for all \spad{i, j}
++
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E map!(-,arr)
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X map!(-,arr)
map:((R,R) -> R,%,%) -> %
++ map(f,a,b) returns \spad{c}, where \spad{c(i,j) = f(a(i,j),b(i,j))}
++ for all \spad{i, j}
++
- ++E adder(a:Integer,b:Integer):Integer == a+b
- ++E arr : ARRAY2 INT := new(5,4,10)
- ++E map(adder,arr,arr)
+ ++X adder(a:Integer,b:Integer):Integer == a+b
+ ++X arr : ARRAY2 INT := new(5,4,10)
+ ++X map(adder,arr,arr)
map:((R,R) -> R,%,%,R) -> %
++ map(f,a,b,r) returns \spad{c}, where \spad{c(i,j) = f(a(i,j),b(i,j))}
@@ -207,10 +207,10 @@ TwoDimensionalArrayCategory(R,Row,Col): Category ==
Definition where
++ else \spad{c(i,j) = f(a(i,j),r)} when \spad{b(i,j)} does not exist;
++ otherwise \spad{c(i,j) = f(r,r)}.
++
- ++E adder(a:Integer,b:Integer):Integer == a+b
- ++E arr1 : ARRAY2 INT := new(5,4,10)
- ++E arr2 : ARRAY2 INT := new(3,3,10)
- ++E map(adder,arr1,arr2,17)
+ ++X adder(a:Integer,b:Integer):Integer == a+b
+ ++X arr1 : ARRAY2 INT := new(5,4,10)
+ ++X arr2 : ARRAY2 INT := new(3,3,10)
+ ++X map(adder,arr1,arr2,17)
add
diff --git a/src/algebra/bags.spad.pamphlet b/src/algebra/bags.spad.pamphlet
index 65efc9e..a2fe3f3 100644
--- a/src/algebra/bags.spad.pamphlet
+++ b/src/algebra/bags.spad.pamphlet
@@ -32,7 +32,7 @@ Stack(S:SetCategory): StackAggregate S with
++ stack([x,y,...,z]) creates a stack with first (top)
++ element x, second element y,...,and last element z.
++
- ++E a:Stack INT:= stack [1,2,3,4,5]
+ ++X a:Stack INT:= stack [1,2,3,4,5]
== add
Rep := Reference List S
@@ -81,7 +81,7 @@ ArrayStack(S:SetCategory): StackAggregate(S) with
++ arrayStack([x,y,...,z]) creates an array stack with first (top)
++ element x, second element y,...,and last element z.
++
- ++E c:ArrayStack INT:= arrayStack [1,2,3,4,5]
+ ++X c:ArrayStack INT:= arrayStack [1,2,3,4,5]
== add
Rep := IndexedFlexibleArray(S,0)
@@ -134,7 +134,7 @@ Queue(S:SetCategory): QueueAggregate S with
++ queue([x,y,...,z]) creates a queue with first (top)
++ element x, second element y,...,and last (bottom) element z.
++
- ++E e:Queue INT:= queue [1,2,3,4,5]
+ ++X e:Queue INT:= queue [1,2,3,4,5]
== Stack S add
Rep := Reference List S
@@ -181,7 +181,7 @@ Dequeue(S:SetCategory): DequeueAggregate S with
++ dequeue([x,y,...,z]) creates a dequeue with first (top or front)
++ element x, second element y,...,and last (bottom or back) element z.
++
- ++E g:Dequeue INT:= dequeue [1,2,3,4,5]
+ ++X g:Dequeue INT:= dequeue [1,2,3,4,5]
== Queue S add
Rep := Reference List S
@@ -376,7 +376,7 @@ Heap(S:OrderedSet): Exports == Implementation where
++ heap(ls) creates a heap of elements consisting of the
++ elements of ls.
++
- ++E i:Heap INT := heap [1,6,3,7,5,2,4]
+ ++X i:Heap INT := heap [1,6,3,7,5,2,4]
Implementation == IndexedFlexibleArray(S,0) add
Rep := IndexedFlexibleArray( S,0)
diff --git a/src/algebra/card.spad.pamphlet b/src/algebra/card.spad.pamphlet
index 14c1ae9..7eb9afa 100644
--- a/src/algebra/card.spad.pamphlet
+++ b/src/algebra/card.spad.pamphlet
@@ -381,62 +381,62 @@ CardinalNumber: Join(OrderedSet, AbelianMonoid, Monoid,
++ \spad{x - y} returns an element z such that
++ \spad{z+y=x} or "failed" if no such element exists.
++
- ++E c2:=2::CardinalNumber
- ++E c2-c2
- ++E A1:=Aleph 1
- ++E A1-c2
+ ++X c2:=2::CardinalNumber
+ ++X c2-c2
+ ++X A1:=Aleph 1
+ ++X A1-c2
"**": (%, %) -> %
++ \spad{x**y} returns \spad{#(X**Y)} where \spad{X**Y} is defined
++ as \spad{\{g| g:Y->X\}}.
++
- ++E c2:=2::CardinalNumber
- ++E c2**c2
- ++E A1:=Aleph 1
- ++E A1**c2
- ++E generalizedContinuumHypothesisAssumed true
- ++E A1**A1
+ ++X c2:=2::CardinalNumber
+ ++X c2**c2
+ ++X A1:=Aleph 1
+ ++X A1**c2
+ ++X generalizedContinuumHypothesisAssumed true
+ ++X A1**A1
Aleph: NonNegativeInteger -> %
++ Aleph(n) provides the named (infinite) cardinal number.
++
- ++E A0:=Aleph 0
+ ++X A0:=Aleph 0
finite?: % -> Boolean
++ finite?(\spad{a}) determines whether
++ \spad{a} is a finite cardinal, i.e. an integer.
++
- ++E c2:=2::CardinalNumber
- ++E finite? c2
- ++E A0:=Aleph 0
- ++E finite? A0
+ ++X c2:=2::CardinalNumber
+ ++X finite? c2
+ ++X A0:=Aleph 0
+ ++X finite? A0
countable?: % -> Boolean
++ countable?(\spad{a}) determines
++ whether \spad{a} is a countable cardinal,
++ i.e. an integer or \spad{Aleph 0}.
++
- ++E c2:=2::CardinalNumber
- ++E countable? c2
- ++E A0:=Aleph 0
- ++E countable? A0
- ++E A1:=Aleph 1
- ++E countable? A1
+ ++X c2:=2::CardinalNumber
+ ++X countable? c2
+ ++X A0:=Aleph 0
+ ++X countable? A0
+ ++X A1:=Aleph 1
+ ++X countable? A1
generalizedContinuumHypothesisAssumed?: () -> Boolean
++ generalizedContinuumHypothesisAssumed?()
++ tests if the hypothesis is currently assumed.
++
- ++E generalizedContinuumHypothesisAssumed?
+ ++X generalizedContinuumHypothesisAssumed?
generalizedContinuumHypothesisAssumed: Boolean -> Boolean
++ generalizedContinuumHypothesisAssumed(bool)
++ is used to dictate whether the hypothesis is to be assumed.
++
- ++E generalizedContinuumHypothesisAssumed true
- ++E a:=Aleph 0
- ++E c:=2**a
- ++E f:=2**c
+ ++X generalizedContinuumHypothesisAssumed true
+ ++X a:=Aleph 0
+ ++X c:=2**a
+ ++X f:=2**c
== add
NNI ==> NonNegativeInteger
FINord ==> -1
diff --git a/src/algebra/carten.spad.pamphlet b/src/algebra/carten.spad.pamphlet
index 8d39805..d1880f4 100644
--- a/src/algebra/carten.spad.pamphlet
+++ b/src/algebra/carten.spad.pamphlet
@@ -1083,94 +1083,94 @@ CartesianTensor(minix, dim, R): Exports ==
Implementation where
coerce: DP(dim, R) -> %
++ coerce(v) views a vector as a rank 1 tensor.
++
- ++E v:DirectProduct(2,Integer):=directProduct [3,4]
- ++E tv:CartesianTensor(1,2,Integer):=v
+ ++X v:DirectProduct(2,Integer):=directProduct [3,4]
+ ++X tv:CartesianTensor(1,2,Integer):=v
coerce: SM(dim, R) -> %
++ coerce(m) views a matrix as a rank 2 tensor.
++
- ++E v:SquareMatrix(2,Integer):=[[1,2],[3,4]]
- ++E tv:CartesianTensor(1,2,Integer):=v
+ ++X v:SquareMatrix(2,Integer):=[[1,2],[3,4]]
+ ++X tv:CartesianTensor(1,2,Integer):=v
coerce: List R -> %
++ coerce([r_1,...,r_dim]) allows tensors to be constructed
++ using lists.
++
- ++E v:=[2,3]
- ++E tv:CartesianTensor(1,2,Integer):=v
+ ++X v:=[2,3]
+ ++X tv:CartesianTensor(1,2,Integer):=v
coerce: List % -> %
++ coerce([t_1,...,t_dim]) allows tensors to be constructed
++ using lists.
++
- ++E v:=[2,3]
- ++E tv:CartesianTensor(1,2,Integer):=v
- ++E tm:CartesianTensor(1,2,Integer):=[tv,tv]
+ ++X v:=[2,3]
+ ++X tv:CartesianTensor(1,2,Integer):=v
+ ++X tm:CartesianTensor(1,2,Integer):=[tv,tv]
rank: % -> NNI
++ rank(t) returns the tensorial rank of t (that is, the
++ number of indices). This is the same as the graded module
++ degree.
++
- ++E CT:=CARTEN(1,2,Integer)
- ++E t0:CT:=8
- ++E rank t0
+ ++X CT:=CARTEN(1,2,Integer)
+ ++X t0:CT:=8
+ ++X rank t0
elt: (%) -> R
++ elt(t) gives the component of a rank 0 tensor.
++
- ++E tv:CartesianTensor(1,2,Integer):=8
- ++E elt(tv)
- ++E tv[]
+ ++X tv:CartesianTensor(1,2,Integer):=8
+ ++X elt(tv)
+ ++X tv[]
elt: (%, I) -> R
++ elt(t,i) gives a component of a rank 1 tensor.
++
- ++E v:=[2,3]
- ++E tv:CartesianTensor(1,2,Integer):=v
- ++E elt(tv,2)
- ++E tv[2]
+ ++X v:=[2,3]
+ ++X tv:CartesianTensor(1,2,Integer):=v
+ ++X elt(tv,2)
+ ++X tv[2]
elt: (%, I, I) -> R
++ elt(t,i,j) gives a component of a rank 2 tensor.
++
- ++E v:=[2,3]
- ++E tv:CartesianTensor(1,2,Integer):=v
- ++E tm:CartesianTensor(1,2,Integer):=[tv,tv]
- ++E elt(tm,2,2)
- ++E tm[2,2]
+ ++X v:=[2,3]
+ ++X tv:CartesianTensor(1,2,Integer):=v
+ ++X tm:CartesianTensor(1,2,Integer):=[tv,tv]
+ ++X elt(tm,2,2)
+ ++X tm[2,2]
elt: (%, I, I, I) -> R
++ elt(t,i,j,k) gives a component of a rank 3 tensor.
++
- ++E v:=[2,3]
- ++E tv:CartesianTensor(1,2,Integer):=v
- ++E tm:CartesianTensor(1,2,Integer):=[tv,tv]
- ++E tn:CartesianTensor(1,2,Integer):=[tm,tm]
- ++E elt(tn,2,2,2)
- ++E tn[2,2,2]
+ ++X v:=[2,3]
+ ++X tv:CartesianTensor(1,2,Integer):=v
+ ++X tm:CartesianTensor(1,2,Integer):=[tv,tv]
+ ++X tn:CartesianTensor(1,2,Integer):=[tm,tm]
+ ++X elt(tn,2,2,2)
+ ++X tn[2,2,2]
elt: (%, I, I, I, I) -> R
++ elt(t,i,j,k,l) gives a component of a rank 4 tensor.
++
- ++E v:=[2,3]
- ++E tv:CartesianTensor(1,2,Integer):=v
- ++E tm:CartesianTensor(1,2,Integer):=[tv,tv]
- ++E tn:CartesianTensor(1,2,Integer):=[tm,tm]
- ++E tp:CartesianTensor(1,2,Integer):=[tn,tn]
- ++E elt(tp,2,2,2,2)
- ++E tp[2,2,2,2]
+ ++X v:=[2,3]
+ ++X tv:CartesianTensor(1,2,Integer):=v
+ ++X tm:CartesianTensor(1,2,Integer):=[tv,tv]
+ ++X tn:CartesianTensor(1,2,Integer):=[tm,tm]
+ ++X tp:CartesianTensor(1,2,Integer):=[tn,tn]
+ ++X elt(tp,2,2,2,2)
+ ++X tp[2,2,2,2]
elt: (%, List I) -> R
++ elt(t,[i1,...,iN]) gives a component of a rank \spad{N} tensor.
++
- ++E v:=[2,3]
- ++E tv:CartesianTensor(1,2,Integer):=v
- ++E tm:CartesianTensor(1,2,Integer):=[tv,tv]
- ++E tn:CartesianTensor(1,2,Integer):=[tm,tm]
- ++E tp:CartesianTensor(1,2,Integer):=[tn,tn]
- ++E tq:CartesianTensor(1,2,Integer):=[tp,tp]
- ++E elt(tq,[2,2,2,2,2])
+ ++X v:=[2,3]
+ ++X tv:CartesianTensor(1,2,Integer):=v
+ ++X tm:CartesianTensor(1,2,Integer):=[tv,tv]
+ ++X tn:CartesianTensor(1,2,Integer):=[tm,tm]
+ ++X tp:CartesianTensor(1,2,Integer):=[tn,tn]
+ ++X tq:CartesianTensor(1,2,Integer):=[tp,tp]
+ ++X elt(tq,[2,2,2,2,2])
-- This specializes the documentation from GradedAlgebra.
product: (%,%) -> %
@@ -1179,11 +1179,11 @@ CartesianTensor(minix, dim, R): Exports ==
Implementation where
++ s and t, then \spad{r} is a rank 4 tensor given by
++ \spad{r(i,j,k,l) = s(i,j)*t(k,l)}.
++
- ++E m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
- ++E Tm:CartesianTensor(1,2,Integer):=m
- ++E n:SquareMatrix(2,Integer):=matrix [[2,3],[0,1]]
- ++E Tn:CartesianTensor(1,2,Integer):=n
- ++E Tmn:=product(Tm,Tn)
+ ++X m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
+ ++X Tm:CartesianTensor(1,2,Integer):=m
+ ++X n:SquareMatrix(2,Integer):=matrix [[2,3],[0,1]]
+ ++X Tn:CartesianTensor(1,2,Integer):=n
+ ++X Tmn:=product(Tm,Tn)
"*": (%, %) -> %
++ s*t is the inner product of the tensors s and t which contracts
@@ -1193,11 +1193,11 @@ CartesianTensor(minix, dim, R): Exports ==
Implementation where
++ This is compatible with the use of \spad{M*v} to denote
++ the matrix-vector inner product.
++
- ++E m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
- ++E Tm:CartesianTensor(1,2,Integer):=m
- ++E v:DirectProduct(2,Integer):=directProduct [3,4]
- ++E Tv:CartesianTensor(1,2,Integer):=v
- ++E Tm*Tv
+ ++X m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
+ ++X Tm:CartesianTensor(1,2,Integer):=m
+ ++X v:DirectProduct(2,Integer):=directProduct [3,4]
+ ++X Tv:CartesianTensor(1,2,Integer):=v
+ ++X Tm*Tv
contract: (%, Integer, %, Integer) -> %
++ contract(t,i,s,j) is the inner product of tenors s and t
@@ -1208,11 +1208,11 @@ CartesianTensor(minix, dim, R): Exports ==
Implementation where
++ the rank 4 \spad{(= 3 + 3 - 2)} tensor given by
++ \spad{r(i,j,k,l) = sum(h=1..dim,s(i,h,j)*t(h,k,l))}.
++
- ++E m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
- ++E Tm:CartesianTensor(1,2,Integer):=m
- ++E v:DirectProduct(2,Integer):=directProduct [3,4]
- ++E Tv:CartesianTensor(1,2,Integer):=v
- ++E Tmv:=contract(Tm,2,Tv,1)
+ ++X m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
+ ++X Tm:CartesianTensor(1,2,Integer):=m
+ ++X v:DirectProduct(2,Integer):=directProduct [3,4]
+ ++X Tv:CartesianTensor(1,2,Integer):=v
+ ++X Tmv:=contract(Tm,2,Tv,1)
contract: (%, Integer, Integer) -> %
++ contract(t,i,j) is the contraction of tensor t which
@@ -1222,11 +1222,11 @@ CartesianTensor(minix, dim, R): Exports ==
Implementation where
++ \spad{r} is the rank 2 \spad{(= 4 - 2)} tensor given by
++ \spad{r(i,j) = sum(h=1..dim,t(h,i,h,j))}.
++
- ++E m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
- ++E Tm:CartesianTensor(1,2,Integer):=m
- ++E v:DirectProduct(2,Integer):=directProduct [3,4]
- ++E Tv:CartesianTensor(1,2,Integer):=v
- ++E Tmv:=contract(Tm,2,1)
+ ++X m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
+ ++X Tm:CartesianTensor(1,2,Integer):=m
+ ++X v:DirectProduct(2,Integer):=directProduct [3,4]
+ ++X Tv:CartesianTensor(1,2,Integer):=v
+ ++X Tmv:=contract(Tm,2,1)
transpose: % -> %
++ transpose(t) exchanges the first and last indices of t.
@@ -1234,9 +1234,9 @@ CartesianTensor(minix, dim, R): Exports == Implementation
where
++ tensor t, then \spad{r} is the rank 4 tensor given by
++ \spad{r(i,j,k,l) = t(l,j,k,i)}.
++
- ++E m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
- ++E Tm:CartesianTensor(1,2,Integer):=m
- ++E transpose(Tm)
+ ++X m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
+ ++X Tm:CartesianTensor(1,2,Integer):=m
+ ++X transpose(Tm)
transpose: (%, Integer, Integer) -> %
++ transpose(t,i,j) exchanges the \spad{i}-th and \spad{j}-th
@@ -1245,10 +1245,10 @@ CartesianTensor(minix, dim, R): Exports ==
Implementation where
++ given by
++ \spad{r(i,j,k,l) = t(i,k,j,l)}.
++
- ++E m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
- ++E tm:CartesianTensor(1,2,Integer):=m
- ++E tn:CartesianTensor(1,2,Integer):=[tm,tm]
- ++E transpose(tn,1,2)
+ ++X m:SquareMatrix(2,Integer):=matrix [[1,2],[4,5]]
+ ++X tm:CartesianTensor(1,2,Integer):=m
+ ++X tn:CartesianTensor(1,2,Integer):=[tm,tm]
+ ++X transpose(tn,1,2)
reindex: (%, List Integer) -> %
++ reindex(t,[i1,...,idim]) permutes the indices of t.
@@ -1257,10 +1257,10 @@ CartesianTensor(minix, dim, R): Exports ==
Implementation where
++ then \spad{r} is the rank for tensor given by
++ \spad{r(i,j,k,l) = t(l,i,j,k)}.
++
- ++E n:SquareMatrix(2,Integer):=matrix [[2,3],[0,1]]
- ++E tn:CartesianTensor(1,2,Integer):=n
- ++E p:=product(tn,tn)
- ++E reindex(p,[4,3,2,1])
+ ++X n:SquareMatrix(2,Integer):=matrix [[2,3],[0,1]]
+ ++X tn:CartesianTensor(1,2,Integer):=n
+ ++X p:=product(tn,tn)
+ ++X reindex(p,[4,3,2,1])
kroneckerDelta: () -> %
++ kroneckerDelta() is the rank 2 tensor defined by
@@ -1268,7 +1268,7 @@ CartesianTensor(minix, dim, R): Exports == Implementation
where
++ \spad{= 1 if i = j}
++ \spad{= 0 if i \^= j}
++
- ++E delta:CartesianTensor(1,2,Integer):=kroneckerDelta()
+ ++X delta:CartesianTensor(1,2,Integer):=kroneckerDelta()
leviCivitaSymbol: () -> %
++ leviCivitaSymbol() is the rank \spad{dim} tensor defined by
@@ -1276,15 +1276,15 @@ CartesianTensor(minix, dim, R): Exports ==
Implementation where
++ if \spad{i1,...,idim} is an even/is nota /is an odd permutation
++ of \spad{minix,...,minix+dim-1}.
++
- ++E lcs:CartesianTensor(1,2,Integer):=leviCivitaSymbol()
+ ++X lcs:CartesianTensor(1,2,Integer):=leviCivitaSymbol()
ravel: % -> List R
++ ravel(t) produces a list of components from a tensor such that
++ \spad{unravel(ravel(t)) = t}.
++
- ++E n:SquareMatrix(2,Integer):=matrix [[2,3],[0,1]]
- ++E tn:CartesianTensor(1,2,Integer):=n
- ++E ravel tn
+ ++X n:SquareMatrix(2,Integer):=matrix [[2,3],[0,1]]
+ ++X tn:CartesianTensor(1,2,Integer):=n
+ ++X ravel tn
unravel: List R -> %
++ unravel(t) produces a tensor from a list of
diff --git a/src/algebra/curve.spad.pamphlet b/src/algebra/curve.spad.pamphlet
index 6128b6b..d0b44da 100644
--- a/src/algebra/curve.spad.pamphlet
+++ b/src/algebra/curve.spad.pamphlet
@@ -37,42 +37,42 @@ FunctionFieldCategory(F, UP, UPUP): Category == Definition
where
++ numberOfComponents() returns the number of absolutely irreducible
++ components.
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
- ++E numberOfComponents()$R
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
+ ++X numberOfComponents()$R
genus : () -> NonNegativeInteger
++ genus() returns the genus of one absolutely irreducible component
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
- ++E genus()$R
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
+ ++X genus()$R
absolutelyIrreducible? : () -> Boolean
++ absolutelyIrreducible?() tests if the curve absolutely irreducible?
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R2 := RadicalFunctionField(INT, P0, P1, 2 * x**2, 4)
- ++E absolutelyIrreducible?()$R2
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R2 := RadicalFunctionField(INT, P0, P1, 2 * x**2, 4)
+ ++X absolutelyIrreducible?()$R2
rationalPoint? : (F, F) -> Boolean
++ rationalPoint?(a, b) tests if \spad{(x=a,y=b)} is on the curve.
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
- ++E rationalPoint?(0,0)$R
- ++E R2 := RadicalFunctionField(INT, P0, P1, 2 * x**2, 4)
- ++E rationalPoint?(0,0)$R2
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
+ ++X rationalPoint?(0,0)$R
+ ++X R2 := RadicalFunctionField(INT, P0, P1, 2 * x**2, 4)
+ ++X rationalPoint?(0,0)$R2
branchPointAtInfinity? : () -> Boolean
++ branchPointAtInfinity?() tests if there is a branch point at infinity.
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
- ++E branchPointAtInfinity?()$R
- ++E R2 := RadicalFunctionField(INT, P0, P1, 2 * x**2, 4)
- ++E branchPointAtInfinity?()$R
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
+ ++X branchPointAtInfinity?()$R
+ ++X R2 := RadicalFunctionField(INT, P0, P1, 2 * x**2, 4)
+ ++X branchPointAtInfinity?()$R
branchPoint? : F -> Boolean
++ branchPoint?(a) tests whether \spad{x = a} is a branch point.
branchPoint? : UP -> Boolean
@@ -92,17 +92,17 @@ FunctionFieldCategory(F, UP, UPUP): Category == Definition
where
integralBasis : () -> Vector $
++ integralBasis() returns the integral basis for the curve.
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
- ++E integralBasis()$R
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
+ ++X integralBasis()$R
integralBasisAtInfinity: () -> Vector $
++ integralBasisAtInfinity() returns the local integral basis at infinity
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
- ++E integralBasisAtInfinity()$R
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
+ ++X integralBasisAtInfinity()$R
integralAtInfinity? : $ -> Boolean
++ integralAtInfinity?() tests if f is locally integral at infinity.
integral? : $ -> Boolean
@@ -121,40 +121,40 @@ FunctionFieldCategory(F, UP, UPUP): Category ==
Definition where
++ where \spad{(w1,...,wn)} is the integral basis of
++ \spadfunFrom{integralBasis}{FunctionFieldCategory}.
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
- ++E integralMatrix()$R
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
+ ++X integralMatrix()$R
inverseIntegralMatrix : () -> Matrix RF
++ inverseIntegralMatrix() returns M such that
++ \spad{M (w1,...,wn) = (1, y, ..., y**(n-1))}
++ where \spad{(w1,...,wn)} is the integral basis of
++ \spadfunFrom{integralBasis}{FunctionFieldCategory}.
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
- ++E inverseIntegralMatrix()$R
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
+ ++X inverseIntegralMatrix()$R
integralMatrixAtInfinity : () -> Matrix RF
++ integralMatrixAtInfinity() returns M such that
++ \spad{(v1,...,vn) = M (1, y, ..., y**(n-1))}
++ where \spad{(v1,...,vn)} is the local integral basis at infinity
++ returned by \spad{infIntBasis()}.
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
- ++E integralMatrixAtInfinity()$R
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
+ ++X integralMatrixAtInfinity()$R
inverseIntegralMatrixAtInfinity: () -> Matrix RF
++ inverseIntegralMatrixAtInfinity() returns M such
++ that \spad{M (v1,...,vn) = (1, y, ..., y**(n-1))}
++ where \spad{(v1,...,vn)} is the local integral basis at infinity
++ returned by \spad{infIntBasis()}.
++
- ++E P0 := UnivariatePolynomial(x, Integer)
- ++E P1 := UnivariatePolynomial(y, Fraction P0)
- ++E R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
- ++E inverseIntegralMatrixAtInfinity()$R
+ ++X P0 := UnivariatePolynomial(x, Integer)
+ ++X P1 := UnivariatePolynomial(y, Fraction P0)
+ ++X R := RadicalFunctionField(INT, P0, P1, 1 - x**20, 20)
+ ++X inverseIntegralMatrixAtInfinity()$R
yCoordinates : $ -> Record(num:Vector(UP), den:UP)
++ yCoordinates(f) returns \spad{[[A1,...,An], D]} such that
++ \spad{f = (A1 + A2 y +...+ An y**(n-1)) / D}.
diff --git a/src/algebra/fr.spad.pamphlet b/src/algebra/fr.spad.pamphlet
index 8c4c8f0..d03f159 100644
--- a/src/algebra/fr.spad.pamphlet
+++ b/src/algebra/fr.spad.pamphlet
@@ -675,38 +675,38 @@ Factored(R: IntegralDomain): Exports == Implementation
where
++ \spadfun{coerce} which would cause the interpreter to do this
++ automatically.
++
- ++E f:=nilFactor(y-x,3)
- ++E expand(f)
+ ++X f:=nilFactor(y-x,3)
+ ++X expand(f)
exponent: % -> Integer
++ exponent(u) returns the exponent of the first factor of
++ \spadvar{u}, or 0 if the factored form consists solely of a unit.
++
- ++E f:=nilFactor(y-x,3)
- ++E exponent(f)
+ ++X f:=nilFactor(y-x,3)
+ ++X exponent(f)
makeFR : (R, List FF) -> %
++ makeFR(unit,listOfFactors) creates a factored object (for
++ use by factoring code).
++
- ++E f:=nilFactor(x-y,3)
- ++E g:=factorList f
- ++E makeFR(z,g)
+ ++X f:=nilFactor(x-y,3)
+ ++X g:=factorList f
+ ++X makeFR(z,g)
factorList : % -> List FF
++ factorList(u) returns the list of factors with flags (for
++ use by factoring code).
++
- ++E f:=nilFactor(x-y,3)
- ++E factorList f
+ ++X f:=nilFactor(x-y,3)
+ ++X factorList f
nilFactor: (R, Integer) -> %
++ nilFactor(base,exponent) creates a factored object with
++ a single factor with no information about the kind of
++ base (flag = "nil").
++
- ++E nilFactor(24,2)
- ++E nilFactor(x-y,3)
+ ++X nilFactor(24,2)
+ ++X nilFactor(x-y,3)
factors: % -> List Record(factor:R, exponent:Integer)
++ factors(u) returns a list of the factors in a form suitable
@@ -715,26 +715,26 @@ Factored(R: IntegralDomain): Exports == Implementation
where
++ object is the product of all the factors and the unit (which
++ can be extracted by \axiom{unit(u)}).
++
- ++E f:=x*y^3-3*x^2*y^2+3*x^3*y-x^4
- ++E factors f
- ++E g:=makeFR(z,factorList f)
- ++E factors g
+ ++X f:=x*y^3-3*x^2*y^2+3*x^3*y-x^4
+ ++X factors f
+ ++X g:=makeFR(z,factorList f)
+ ++X factors g
irreducibleFactor: (R, Integer) -> %
++ irreducibleFactor(base,exponent) creates a factored object with
++ a single factor whose base is asserted to be irreducible
++ (flag = "irred").
++
- ++E a:=irreducibleFactor(3,1)
- ++E nthFlag(a,1)
+ ++X a:=irreducibleFactor(3,1)
+ ++X nthFlag(a,1)
nthExponent: (%, Integer) -> Integer
++ nthExponent(u,n) returns the exponent of the nth factor of
++ \spadvar{u}. If \spadvar{n} is not a valid index for a factor
++ (for example, less than 1 or too big), 0 is returned.
++
- ++E a:=factor 9720000
- ++E nthExponent(a,2)
+ ++X a:=factor 9720000
+ ++X nthExponent(a,2)
nthFactor: (%,Integer) -> R
++ nthFactor(u,n) returns the base of the nth factor of
@@ -742,38 +742,38 @@ Factored(R: IntegralDomain): Exports == Implementation
where
++ (for example, less than 1 or too big), 1 is returned. If
++ \spadvar{u} consists only of a unit, the unit is returned.
++
- ++E a:=factor 9720000
- ++E nthFactor(a,2)
+ ++X a:=factor 9720000
+ ++X nthFactor(a,2)
nthFlag: (%,Integer) -> fUnion
++ nthFlag(u,n) returns the information flag of the nth factor of
++ \spadvar{u}. If \spadvar{n} is not a valid index for a factor
++ (for example, less than 1 or too big), "nil" is returned.
++
- ++E a:=factor 9720000
- ++E nthFlag(a,2)
+ ++X a:=factor 9720000
+ ++X nthFlag(a,2)
numberOfFactors : % -> NonNegativeInteger
++ numberOfFactors(u) returns the number of factors in \spadvar{u}.
++
- ++E a:=factor 9720000
- ++E numberOfFactors a
+ ++X a:=factor 9720000
+ ++X numberOfFactors a
primeFactor: (R,Integer) -> %
++ primeFactor(base,exponent) creates a factored object with
++ a single factor whose base is asserted to be prime
++ (flag = "prime").
++
- ++E a:=primeFactor(3,4)
- ++E nthFlag(a,1)
+ ++X a:=primeFactor(3,4)
+ ++X nthFlag(a,1)
sqfrFactor: (R,Integer) -> %
++ sqfrFactor(base,exponent) creates a factored object with
++ a single factor whose base is asserted to be square-free
++ (flag = "sqfr").
++
- ++E a:=sqfrFactor(3,5)
- ++E nthFlag(a,1)
+ ++X a:=sqfrFactor(3,5)
+ ++X nthFlag(a,1)
flagFactor: (R,Integer, fUnion) -> %
++ flagFactor(base,exponent,flag) creates a factored object with
@@ -783,10 +783,10 @@ Factored(R: IntegralDomain): Exports == Implementation
where
unit: % -> R
++ unit(u) extracts the unit part of the factorization.
++
- ++E f:=x*y^3-3*x^2*y^2+3*x^3*y-x^4
- ++E unit f
- ++E g:=makeFR(z,factorList f)
- ++E unit g
+ ++X f:=x*y^3-3*x^2*y^2+3*x^3*y-x^4
+ ++X unit f
+ ++X g:=makeFR(z,factorList f)
+ ++X unit g
unitNormalize: % -> %
++ unitNormalize(u) normalizes the unit part of the factorization.
@@ -799,11 +799,11 @@ Factored(R: IntegralDomain): Exports == Implementation
where
++ the information flags (sets them to "nil") because the effect of
++ \userfun{fn} is clearly not known in general.
++
- ++E m(a:Factored Polynomial Integer):Factored Polynomial Integer == a^2
- ++E f:=x*y^3-3*x^2*y^2+3*x^3*y-x^4
- ++E map(m,f)
- ++E g:=makeFR(z,factorList f)
- ++E map(m,g)
+ ++X m(a:Factored Polynomial Integer):Factored Polynomial Integer == a^2
+ ++X f:=x*y^3-3*x^2*y^2+3*x^3*y-x^4
+ ++X map(m,f)
+ ++X g:=makeFR(z,factorList f)
+ ++X map(m,g)
-- the following operations are conditional on R
diff --git a/src/algebra/listgcd.spad.pamphlet
b/src/algebra/listgcd.spad.pamphlet
index 8cbcebe..8c74a22 100644
--- a/src/algebra/listgcd.spad.pamphlet
+++ b/src/algebra/listgcd.spad.pamphlet
@@ -35,8 +35,8 @@ HeuGcd (BP):C == T
gcd : List BP -> BP
++ gcd([f1,..,fk]) = gcd of the polynomials fi.
++
- ++E gcd([671*671*x^2-1,671*671*x^2+2*671*x+1])
- ++E gcd([7*x^2+1,(7*x^2+1)^2])
+ ++X gcd([671*671*x^2-1,671*671*x^2+2*671*x+1])
+ ++X gcd([7*x^2+1,(7*x^2+1)^2])
gcdprim : List BP -> BP
++ gcdprim([f1,..,fk]) = gcd of k PRIMITIVE univariate polynomials
diff --git a/src/algebra/mappkg.spad.pamphlet b/src/algebra/mappkg.spad.pamphlet
index ca1dc5f..030d679 100644
--- a/src/algebra/mappkg.spad.pamphlet
+++ b/src/algebra/mappkg.spad.pamphlet
@@ -1783,28 +1783,28 @@ MappingPackage4(A:SetCategory, B:Ring):
"+": (A->B, A->B) -> (A->B)
++ \spad(+) does functional addition
++
- ++E f:=(x:INT):INT +-> 3*x
- ++E g:=(x:INT):INT +-> 2*x+3
- ++E (f+g)(4)
+ ++X f:=(x:INT):INT +-> 3*x
+ ++X g:=(x:INT):INT +-> 2*x+3
+ ++X (f+g)(4)
"-": (A->B, A->B) -> (A->B)
++ \spad(+) does functional addition
++
- ++E f:=(x:INT):INT +-> 3*x
- ++E g:=(x:INT):INT +-> 2*x+3
- ++E (f-g)(4)
+ ++X f:=(x:INT):INT +-> 3*x
+ ++X g:=(x:INT):INT +-> 2*x+3
+ ++X (f-g)(4)
"*": (A->B, A->B) -> (A->B)
++ \spad(+) does functional addition
++
- ++E f:=(x:INT):INT +-> 3*x
- ++E g:=(x:INT):INT +-> 2*x+3
- ++E (f*g)(4)
+ ++X f:=(x:INT):INT +-> 3*x
+ ++X g:=(x:INT):INT +-> 2*x+3
+ ++X (f*g)(4)
"/": (A->Expression(Integer), A->Expression(Integer)) ->
(A->Expression(Integer))
++ \spad(+) does functional addition
++
- ++E p:=(x:EXPR(INT)):EXPR(INT)+->3*x
- ++E q:=(x:EXPR(INT)):EXPR(INT)+->2*x+3
- ++E (p/q)(4)
- ++E (p/q)(x)
+ ++X p:=(x:EXPR(INT)):EXPR(INT)+->3*x
+ ++X q:=(x:EXPR(INT)):EXPR(INT)+->2*x+3
+ ++X (p/q)(4)
+ ++X (p/q)(x)
== add
fab ==> (A -> B)
faei ==> (A -> Expression(Integer))
diff --git a/src/algebra/mkfunc.spad.pamphlet b/src/algebra/mkfunc.spad.pamphlet
index 840aa2e..6a34b58 100644
--- a/src/algebra/mkfunc.spad.pamphlet
+++ b/src/algebra/mkfunc.spad.pamphlet
@@ -34,8 +34,8 @@ InputForm():
++ \spad{binary(op, [a1,...,an])} returns the input form
++ corresponding to \spad{a1 op a2 op ... op an}.
++
- ++E a:=[1,2,3]::List(InputForm)
- ++E binary(_+::InputForm,a)
+ ++X a:=[1,2,3]::List(InputForm)
+ ++X binary(_+::InputForm,a)
function : (%, List Symbol, Symbol) -> %
++ \spad{function(code, [x1,...,xn], f)} returns the input form
diff --git a/src/algebra/plot.spad.pamphlet b/src/algebra/plot.spad.pamphlet
index 81c4846..4c9ed69 100644
--- a/src/algebra/plot.spad.pamphlet
+++ b/src/algebra/plot.spad.pamphlet
@@ -146,8 +146,8 @@ Plot(): Exports == Implementation where
++ plot(f,a..b) plots the function \spad{f(x)}
++ on the interval \spad{[a,b]}.
++
- ++E fp:=(t:DFLOAT):DFLOAT +-> sin(t)
- ++E plot(fp,-1.0..1.0)$PLOT
+ ++X fp:=(t:DFLOAT):DFLOAT +-> sin(t)
+ ++X plot(fp,-1.0..1.0)$PLOT
plot: (F -> F,R,R) -> %
++ plot(f,a..b,c..d) plots the function \spad{f(x)} on the interval
diff --git a/src/algebra/radix.spad.pamphlet b/src/algebra/radix.spad.pamphlet
index 28185f1..06bb6b8 100644
--- a/src/algebra/radix.spad.pamphlet
+++ b/src/algebra/radix.spad.pamphlet
@@ -724,7 +724,7 @@ BinaryExpansion(): Exports == Implementation where
binary: Fraction Integer -> %
++ binary(r) converts a rational number to a binary expansion.
++
- ++E binary(22/7)
+ ++X binary(22/7)
Implementation ==> RadixExpansion(2) add
binary r == r :: %
diff --git a/src/algebra/stream.spad.pamphlet b/src/algebra/stream.spad.pamphlet
index d69cbfb..e30e3b4 100644
--- a/src/algebra/stream.spad.pamphlet
+++ b/src/algebra/stream.spad.pamphlet
@@ -30,40 +30,40 @@ LazyStreamAggregate(S:Type): Category == StreamAggregate(S)
with
++ st which do not satisfy the predicate f.
++ Note: \spad{remove(f,st) = [x for x in st | not f(x)]}.
++
- ++E m:=[i for i in 1..]
- ++E f(i:PositiveInteger):Boolean == even? i
- ++E remove(f,m)
+ ++X m:=[i for i in 1..]
+ ++X f(i:PositiveInteger):Boolean == even? i
+ ++X remove(f,m)
select: (S -> Boolean,%) -> %
++ select(f,st) returns a stream consisting of those elements of stream
++ st satisfying the predicate f.
++ Note: \spad{select(f,st) = [x for x in st | f(x)]}.
++
- ++E m:=[i for i in 0..]
- ++E select(x+->prime? x,m)
+ ++X m:=[i for i in 0..]
+ ++X select(x+->prime? x,m)
explicitEntries?: % -> Boolean
++ explicitEntries?(s) returns true if the stream s has
++ explicitly computed entries, and false otherwise.
++
- ++E m:=[i for i in 0..]
- ++E explicitEntries? m
+ ++X m:=[i for i in 0..]
+ ++X explicitEntries? m
explicitlyEmpty?: % -> Boolean
++ explicitlyEmpty?(s) returns true if the stream is an
++ (explicitly) empty stream.
++ Note: this is a null test which will not cause lazy evaluation.
++
- ++E m:=[i for i in 0..]
- ++E explicitlyEmpty? m
+ ++X m:=[i for i in 0..]
+ ++X explicitlyEmpty? m
lazy?: % -> Boolean
++ lazy?(s) returns true if the first node of the stream s
++ is a lazy evaluation mechanism which could produce an
++ additional entry to s.
++
- ++E m:=[i for i in 0..]
- ++E lazy? m
+ ++X m:=[i for i in 0..]
+ ++X lazy? m
lazyEvaluate: % -> %
++ lazyEvaluate(s) causes one lazy evaluation of stream s.
@@ -76,24 +76,24 @@ LazyStreamAggregate(S:Type): Category == StreamAggregate(S)
with
++ Caution: this function should only be called after a \spad{empty?} test
++ has been made since there no error check.
++
- ++E m:=[i for i in 0..]
- ++E frst m
+ ++X m:=[i for i in 0..]
+ ++X frst m
rst: % -> %
++ rst(s) returns a pointer to the next node of stream s.
++ Caution: this function should only be called after a \spad{empty?} test
++ has been made since there no error check.
++
- ++E m:=[i for i in 0..]
- ++E rst m
+ ++X m:=[i for i in 0..]
+ ++X rst m
numberOfComputedEntries: % -> NonNegativeInteger
++ numberOfComputedEntries(st) returns the number of explicitly
++ computed entries of stream st which exist immediately prior to the time
++ this function is called.
++
- ++E m:=[i for i in 0..]
- ++E numberOfComputedEntries m
+ ++X m:=[i for i in 0..]
+ ++X numberOfComputedEntries m
extend: (%,Integer) -> %
++ extend(st,n) causes entries to be computed, if necessary,
@@ -101,21 +101,21 @@ LazyStreamAggregate(S:Type): Category ==
StreamAggregate(S) with
++ that all entries of 'st' will be computed if 'st' is finite
++ with length <= n.
++
- ++E m:=[i for i in 0..]
- ++E numberOfComputedEntries m
- ++E extend(m,20)
- ++E numberOfComputedEntries m
+ ++X m:=[i for i in 0..]
+ ++X numberOfComputedEntries m
+ ++X extend(m,20)
+ ++X numberOfComputedEntries m
complete: % -> %
++ complete(st) causes all entries of 'st' to be computed.
++ this function should only be called on streams which are
++ known to be finite.
++
- ++E m:=[i for i in 1..]
- ++E n:=filterUntil(i+->i>100,m)
- ++E numberOfComputedEntries n
- ++E complete n
- ++E numberOfComputedEntries n
+ ++X m:=[i for i in 1..]
+ ++X n:=filterUntil(i+->i>100,m)
+ ++X numberOfComputedEntries n
+ ++X complete n
+ ++X numberOfComputedEntries n
add
@@ -551,29 +551,29 @@ CyclicStreamTools(S,ST): Exports == Implementation where
++ cycleElt(s) returns a pointer to a node in the cycle if the stream
++ s is cyclic and returns "failed" if s is not cyclic
++
- ++E p:=repeating([1,2,3])
- ++E q:=cons(4,p)
- ++E cycleElt q
- ++E r:=[1,2,3]::Stream(Integer)
- ++E cycleElt r
+ ++X p:=repeating([1,2,3])
+ ++X q:=cons(4,p)
+ ++X cycleElt q
+ ++X r:=[1,2,3]::Stream(Integer)
+ ++X cycleElt r
computeCycleLength: ST -> NonNegativeInteger
++ computeCycleLength(s) returns the length of the cycle of a
++ cyclic stream t, where s is a pointer to a node in the
++ cyclic part of t.
++
- ++E p:=repeating([1,2,3])
- ++E q:=cons(4,p)
- ++E computeCycleLength(cycleElt(q))
+ ++X p:=repeating([1,2,3])
+ ++X q:=cons(4,p)
+ ++X computeCycleLength(cycleElt(q))
computeCycleEntry: (ST,ST) -> ST
++ computeCycleEntry(x,cycElt), where cycElt is a pointer to a
++ node in the cyclic part of the cyclic stream x, returns a
++ pointer to the first node in the cycle
++
- ++E p:=repeating([1,2,3])
- ++E q:=cons(4,p)
- ++E computeCycleEntry(q,cycleElt(q))
+ ++X p:=repeating([1,2,3])
+ ++X q:=cons(4,p)
+ ++X computeCycleEntry(q,cycleElt(q))
Implementation ==> add
@@ -817,31 +817,31 @@ Stream(S): Exports == Implementation where
coerce: L S -> %
++ coerce(l) converts a list l to a stream.
++
- ++E m:=[1,2,3,4,5,6,7,8,9,10,11,12]
- ++E coerce(m)@Stream(Integer)
- ++E m::Stream(Integer)
+ ++X m:=[1,2,3,4,5,6,7,8,9,10,11,12]
+ ++X coerce(m)@Stream(Integer)
+ ++X m::Stream(Integer)
repeating: L S -> %
++ repeating(l) is a repeating stream whose period is the list l.
++
- ++E m:=repeating([-1,0,1,2,3])
+ ++X m:=repeating([-1,0,1,2,3])
if S has SetCategory then
repeating?: (L S,%) -> B
++ repeating?(l,s) returns true if a stream s is periodic
++ with period l, and false otherwise.
++
- ++E m:=[1,2,3]
- ++E n:=repeating(m)
- ++E repeating?(m,n)
+ ++X m:=[1,2,3]
+ ++X n:=repeating(m)
+ ++X repeating?(m,n)
findCycle: (NNI,%) -> Record(cycle?: B, prefix: NNI, period: NNI)
++ findCycle(n,st) determines if st is periodic within n.
++
- ++E m:=[1,2,3]
- ++E n:=repeating(m)
- ++E findCycle(3,n)
- ++E findCycle(2,n)
+ ++X m:=[1,2,3]
+ ++X n:=repeating(m)
+ ++X findCycle(3,n)
+ ++X findCycle(2,n)
delay: (() -> %) -> %
++ delay(f) creates a stream with a lazy evaluation defined by
@@ -852,26 +852,26 @@ Stream(S): Exports == Implementation where
++ and whose \spad{rest} is s.
++ Note: \spad{cons(a,s) = concat(a,s)}.
++
- ++E m:=[1,2,3]
- ++E n:=repeating(m)
- ++E cons(4,n)
+ ++X m:=[1,2,3]
+ ++X n:=repeating(m)
+ ++X cons(4,n)
if S has SetCategory then
output: (I, %) -> Void
++ output(n,st) computes and displays the first n entries
++ of st.
++
- ++E m:=[1,2,3]
- ++E n:=repeating(m)
- ++E output(5,n)
+ ++X m:=[1,2,3]
+ ++X n:=repeating(m)
+ ++X output(5,n)
showAllElements: % -> OUT
++ showAllElements(s) creates an output form which displays all
++ computed elements.
++
- ++E m:=[1,2,3,4,5,6,7,8,9,10,11,12]
- ++E n:=m::Stream(PositiveInteger)
- ++E showAllElements n
+ ++X m:=[1,2,3,4,5,6,7,8,9,10,11,12]
+ ++X n:=m::Stream(PositiveInteger)
+ ++X showAllElements n
showAll?: () -> B
++ showAll?() returns true if all computed entries of streams
@@ -881,44 +881,44 @@ Stream(S): Exports == Implementation where
++ setrest!(x,n,y) sets rest(x,n) to y. The function will expand
++ cycles if necessary.
++
- ++E p:=[i for i in 1..]
- ++E q:=[i for i in 9..]
- ++E setrest!(p,4,q)
- ++E p
+ ++X p:=[i for i in 1..]
+ ++X q:=[i for i in 9..]
+ ++X setrest!(p,4,q)
+ ++X p
generate: (() -> S) -> %
++ generate(f) creates an infinite stream all of whose elements are
++ equal to \spad{f()}.
++ Note: \spad{generate(f) = [f(),f(),f(),...]}.
++
- ++E f():Integer == 1
- ++E generate(f)
+ ++X f():Integer == 1
+ ++X generate(f)
generate: (S -> S,S) -> %
++ generate(f,x) creates an infinite stream whose first element is
++ x and whose nth element (\spad{n > 1}) is f applied to the previous
++ element. Note: \spad{generate(f,x) = [x,f(x),f(f(x)),...]}.
++
- ++E f(x:Integer):Integer == x+10
- ++E generate(f,10)
+ ++X f(x:Integer):Integer == x+10
+ ++X generate(f,10)
filterWhile: (S -> Boolean,%) -> %
++ filterWhile(p,s) returns \spad{[x0,x1,...,x(n-1)]} where
++ \spad{s = [x0,x1,x2,..]} and
++ n is the smallest index such that \spad{p(xn) = false}.
++
- ++E m:=[i for i in 1..]
- ++E f(x:PositiveInteger):Boolean == x < 5
- ++E filterWhile(f,m)
+ ++X m:=[i for i in 1..]
+ ++X f(x:PositiveInteger):Boolean == x < 5
+ ++X filterWhile(f,m)
filterUntil: (S -> Boolean,%) -> %
++ filterUntil(p,s) returns \spad{[x0,x1,...,x(n)]} where
++ \spad{s = [x0,x1,x2,..]} and
++ n is the smallest index such that \spad{p(xn) = true}.
++
- ++E m:=[i for i in 1..]
- ++E f(x:PositiveInteger):Boolean == x < 5
- ++E filterUntil(f,m)
+ ++X m:=[i for i in 1..]
+ ++X f(x:PositiveInteger):Boolean == x < 5
+ ++X filterUntil(f,m)
-- if S has SetCategory then
-- map: ((S,S) -> S,%,%,S) -> %
@@ -1446,10 +1446,10 @@ StreamFunctions1(S:Type): Exports == Implementation
where
++ concat(u) returns the left-to-right concatentation of the
++ streams in u. Note: \spad{concat(u) = reduce(concat,u)}.
++
- ++E m:=[i for i in 10..]
- ++E n:=[j for j in 1.. | prime? j]
- ++E p:=[m,n]::Stream(Stream(PositiveInteger))
- ++E concat(p)
+ ++X m:=[i for i in 10..]
+ ++X n:=[j for j in 1.. | prime? j]
+ ++X p:=[m,n]::Stream(Stream(PositiveInteger))
+ ++X concat(p)
Implementation ==> add
@@ -1476,9 +1476,9 @@ StreamFunctions2(A:Type,B:Type): Exports ==
Implementation where
++ to the corresponding elements of s.
++ Note: \spad{map(f,[x0,x1,x2,...]) = [f(x0),f(x1),f(x2),..]}.
++
- ++E m:=[i for i in 1..]
- ++E f(i:PositiveInteger):PositiveInteger==i**2
- ++E map(f,m)
+ ++X m:=[i for i in 1..]
+ ++X f(i:PositiveInteger):PositiveInteger==i**2
+ ++X map(f,m)
scan: (B,((A,B) -> B),ST A) -> ST B
++ scan(b,h,[x0,x1,x2,...]) returns \spad{[y0,y1,y2,...]}, where
@@ -1486,9 +1486,9 @@ StreamFunctions2(A:Type,B:Type): Exports ==
Implementation where
++ \spad{y1 = h(x1,y0)},\spad{...}
++ \spad{yn = h(xn,y(n-1))}.
++
- ++E m:=[i for i in 1..]::Stream(Integer)
- ++E f(i:Integer,j:Integer):Integer==i+j
- ++E scan(1,f,m)
+ ++X m:=[i for i in 1..]::Stream(Integer)
+ ++X f(i:Integer,j:Integer):Integer==i+j
+ ++X scan(1,f,m)
reduce: (B,(A,B) -> B,ST A) -> B
++ reduce(b,f,u), where u is a finite stream \spad{[x0,x1,...,xn]},
@@ -1497,9 +1497,9 @@ StreamFunctions2(A:Type,B:Type): Exports ==
Implementation where
++ r1 = f(x1,r0),...,
++ r(n) = f(xn,r(n-1))}.
++
- ++E m:=[i for i in 1..300]::Stream(Integer)
- ++E f(i:Integer,j:Integer):Integer==i+j
- ++E reduce(1,f,m)
+ ++X m:=[i for i in 1..300]::Stream(Integer)
+ ++X f(i:Integer,j:Integer):Integer==i+j
+ ++X reduce(1,f,m)
-- rreduce: (B,(A,B) -> B,ST A) -> B
-- ++ reduce(b,h,[x0,x1,..,xn]) = h(x1,h(x2(..,h(x(n-1),h(xn,b))..)
@@ -1554,10 +1554,10 @@ StreamFunctions3(A,B,C): Exports == Implementation where
++ \spad{map(f,[x0,x1,x2,..],[y0,y1,y2,..]) = [f(x0,y0),f(x1,y1),..]}.
++
++S
- ++E m:=[i for i in 1..]::Stream(Integer)
- ++E n:=[i for i in 1..]::Stream(Integer)
- ++E f(i:Integer,j:Integer):Integer == i+j
- ++E map(f,m,n)
+ ++X m:=[i for i in 1..]::Stream(Integer)
+ ++X n:=[i for i in 1..]::Stream(Integer)
+ ++X f(i:Integer,j:Integer):Integer == i+j
+ ++X map(f,m,n)
Implementation ==> add
diff --git a/src/algebra/string.spad.pamphlet b/src/algebra/string.spad.pamphlet
index 9cae78b..8ee1e1b 100644
--- a/src/algebra/string.spad.pamphlet
+++ b/src/algebra/string.spad.pamphlet
@@ -232,81 +232,81 @@ Character: OrderedFinite() with
++ ord(c) provides an integral code corresponding to the
++ character c. It is always true that \spad{char ord c = c}.
++
- ++E chars := [char "a", char "A", char "X", char "8", char "+"]
- ++E [ord c for c in chars]
+ ++X chars := [char "a", char "A", char "X", char "8", char "+"]
+ ++X [ord c for c in chars]
char: Integer -> %
++ char(i) provides a character corresponding to the integer
++ code i. It is always true that \spad{ord char i = i}.
++
- ++E [char c for c in [97,65,88,56,43]]
+ ++X [char c for c in [97,65,88,56,43]]
char: String -> %
++ char(s) provides a character from a string s of length one.
++
- ++E [char c for c in ["a","A","X","8","+"]]
+ ++X [char c for c in ["a","A","X","8","+"]]
space: () -> %
++ space() provides the blank character.
++
- ++E space()
+ ++X space()
quote: () -> %
++ quote() provides the string quote character, \spad{"}.
++
- ++E quote()
+ ++X quote()
escape: () -> %
++ escape() provides the escape character, \spad{_}, which
++ is used to allow quotes and other characters {\em within}
++ strings.
++
- ++E escape()
+ ++X escape()
upperCase: % -> %
++ upperCase(c) converts a lower case letter to the corresponding
++ upper case letter. If c is not a lower case letter, then
++ it is returned unchanged.
++
- ++E chars := [char "a", char "A", char "X", char "8", char "+"]
- ++E [upperCase c for c in chars]
+ ++X chars := [char "a", char "A", char "X", char "8", char "+"]
+ ++X [upperCase c for c in chars]
lowerCase: % -> %
++ lowerCase(c) converts an upper case letter to the corresponding
++ lower case letter. If c is not an upper case letter, then
++ it is returned unchanged.
++
- ++E chars := [char "a", char "A", char "X", char "8", char "+"]
- ++E [lowerCase c for c in chars]
+ ++X chars := [char "a", char "A", char "X", char "8", char "+"]
+ ++X [lowerCase c for c in chars]
digit?: % -> Boolean
++ digit?(c) tests if c is a digit character,
++ i.e. one of 0..9.
++
- ++E chars := [char "a", char "A", char "X", char "8", char "+"]
- ++E [digit? c for c in chars]
+ ++X chars := [char "a", char "A", char "X", char "8", char "+"]
+ ++X [digit? c for c in chars]
hexDigit?: % -> Boolean
++ hexDigit?(c) tests if c is a hexadecimal numeral,
++ i.e. one of 0..9, a..f or A..F.
++
- ++E chars := [char "a", char "A", char "X", char "8", char "+"]
- ++E [hexDigit? c for c in chars]
+ ++X chars := [char "a", char "A", char "X", char "8", char "+"]
+ ++X [hexDigit? c for c in chars]
alphabetic?: % -> Boolean
++ alphabetic?(c) tests if c is a letter,
++ i.e. one of a..z or A..Z.
++
- ++E chars := [char "a", char "A", char "X", char "8", char "+"]
- ++E [alphabetic? c for c in chars]
+ ++X chars := [char "a", char "A", char "X", char "8", char "+"]
+ ++X [alphabetic? c for c in chars]
upperCase?: % -> Boolean
++ upperCase?(c) tests if c is an upper case letter,
++ i.e. one of A..Z.
++
- ++E chars := [char "a", char "A", char "X", char "8", char "+"]
- ++E [upperCase? c for c in chars]
+ ++X chars := [char "a", char "A", char "X", char "8", char "+"]
+ ++X [upperCase? c for c in chars]
lowerCase?: % -> Boolean
++ lowerCase?(c) tests if c is an lower case letter,
++ i.e. one of a..z.
++
- ++E chars := [char "a", char "A", char "X", char "8", char "+"]
- ++E [lowerCase? c for c in chars]
+ ++X chars := [char "a", char "A", char "X", char "8", char "+"]
+ ++X [lowerCase? c for c in chars]
alphanumeric?: % -> Boolean
++ alphanumeric?(c) tests if c is either a letter or number,
++ i.e. one of 0..9, a..z or A..Z.
++
- ++E chars := [char "a", char "A", char "X", char "8", char "+"]
- ++E [alphanumeric? c for c in chars]
+ ++X chars := [char "a", char "A", char "X", char "8", char "+"]
+ ++X [alphanumeric? c for c in chars]
== add
diff --git a/src/algebra/tree.spad.pamphlet b/src/algebra/tree.spad.pamphlet
index 0a208e0..ab2e87d 100644
--- a/src/algebra/tree.spad.pamphlet
+++ b/src/algebra/tree.spad.pamphlet
@@ -32,50 +32,50 @@ Tree(S: SetCategory): T==C where
tree: (S,List %) -> %
++ tree(nd,ls) creates a tree with value nd, and children ls.
++
- ++E t1:=tree [1,2,3,4]
- ++E tree(5,[t1])
+ ++X t1:=tree [1,2,3,4]
+ ++X tree(5,[t1])
tree: List S -> %
++ tree(ls) creates a tree from a list of elements of s.
++
- ++E tree [1,2,3,4]
+ ++X tree [1,2,3,4]
tree: S -> %
++ tree(nd) creates a tree with value nd, and no children
++
- ++E tree 6
+ ++X tree 6
cyclic?: % -> Boolean
++ cyclic?(t) tests if t is a cyclic tree.
++
- ++E t1:=tree [1,2,3,4]
- ++E cyclic? t1
+ ++X t1:=tree [1,2,3,4]
+ ++X cyclic? t1
cyclicCopy: % -> %
++ cyclicCopy(l) makes a copy of a (possibly) cyclic tree l.
++
- ++E t1:=tree [1,2,3,4]
- ++E cyclicCopy t1
+ ++X t1:=tree [1,2,3,4]
+ ++X cyclicCopy t1
cyclicEntries: % -> List %
++ cyclicEntries(t) returns a list of top-level cycles in tree t.
++
- ++E t1:=tree [1,2,3,4]
- ++E cyclicEntries t1
+ ++X t1:=tree [1,2,3,4]
+ ++X cyclicEntries t1
cyclicEqual?: (%, %) -> Boolean
++ cyclicEqual?(t1, t2) tests of two cyclic trees have
++ the same structure.
++
- ++E t1:=tree [1,2,3,4]
- ++E t2:=tree [1,2,3,4]
- ++E cyclicEqual?(t1,t2)
+ ++X t1:=tree [1,2,3,4]
+ ++X t2:=tree [1,2,3,4]
+ ++X cyclicEqual?(t1,t2)
cyclicParents: % -> List %
++ cyclicParents(t) returns a list of cycles that are parents of t.
++
- ++E t1:=tree [1,2,3,4]
- ++E cyclicParents t1
+ ++X t1:=tree [1,2,3,4]
+ ++X cyclicParents t1
C== add
cycleTreeMax ==> 5
@@ -407,15 +407,15 @@ BinaryTree(S: SetCategory): Exports == Implementation
where
++ binaryTree(v) is an non-empty binary tree
++ with value v, and left and right empty.
++
- ++E t1:=binaryTree([1,2,3])
+ ++X t1:=binaryTree([1,2,3])
binaryTree: (%,S,%) -> %
++ binaryTree(l,v,r) creates a binary tree with
++ value v with left subtree l and right subtree r.
++
- ++E t1:=binaryTree([1,2,3])
- ++E t2:=binaryTree([4,5,6])
- ++E binaryTree(t1,[7,8,9],t2)
+ ++X t1:=binaryTree([1,2,3])
+ ++X t2:=binaryTree([4,5,6])
+ ++X binaryTree(t1,[7,8,9],t2)
Implementation == add
Rep := List Tree S
@@ -669,26 +669,26 @@ BinarySearchTree(S: OrderedSet): Exports ==
Implementation where
binarySearchTree: List S -> %
++ binarySearchTree(l) \undocumented
++
- ++E binarySearchTree [1,2,3,4]
+ ++X binarySearchTree [1,2,3,4]
insert_!: (S,%) -> %
++ insert!(x,b) inserts element x as leaves into binary search tree b.
++
- ++E t1:=binarySearchTree [1,2,3,4]
- ++E insert!(5,t1)
+ ++X t1:=binarySearchTree [1,2,3,4]
+ ++X insert!(5,t1)
insertRoot_!: (S,%) -> %
++ insertRoot!(x,b) inserts element x as a root of binary search tree b.
++
- ++E t1:=binarySearchTree [1,2,3,4]
- ++E insertRoot!(5,t1)
+ ++X t1:=binarySearchTree [1,2,3,4]
+ ++X insertRoot!(5,t1)
split: (S,%) -> Record(less: %, greater: %)
++ split(x,b) splits binary tree b into two trees, one with elements
++ greater than x, the other with elements less than x.
++
- ++E t1:=binarySearchTree [1,2,3,4]
- ++E split(3,t1)
+ ++X t1:=binarySearchTree [1,2,3,4]
+ ++X split(3,t1)
Implementation == BinaryTree(S) add
Rep := BinaryTree(S)
@@ -730,14 +730,14 @@ BinaryTournament(S: OrderedSet): Exports ==
Implementation where
++ binaryTournament(ls) creates a binary tournament with the
++ elements of ls as values at the nodes.
++
- ++E binaryTournament [1,2,3,4]
+ ++X binaryTournament [1,2,3,4]
insert_!: (S,%) -> %
++ insert!(x,b) inserts element x as leaves into binary tournament b.
++
- ++E t1:=binaryTournament [1,2,3,4]
- ++E insert!(5,t1)
- ++E t1
+ ++X t1:=binaryTournament [1,2,3,4]
+ ++X insert!(5,t1)
+ ++X t1
Implementation == BinaryTree(S) add
Rep := BinaryTree(S)
@@ -970,14 +970,14 @@ BalancedBinaryTree(S: SetCategory): Exports ==
Implementation where
++ balancedBinaryTree(n, s) creates a balanced binary tree with
++ n nodes each with value s.
++
- ++E balancedBinaryTree(4, 0)
+ ++X balancedBinaryTree(4, 0)
setleaves_!: (%, List S) -> %
++ setleaves!(t, ls) sets the leaves of t in left-to-right order
++ to the elements of ls.
++
- ++E t1:=balancedBinaryTree(4, 0)
- ++E setleaves!(t1,[1,2,3,4])
+ ++X t1:=balancedBinaryTree(4, 0)
+ ++X setleaves!(t1,[1,2,3,4])
mapUp_!: (%, (S,S) -> S) -> S
++ mapUp!(t,f) traverses balanced binary tree t in an "endorder"
@@ -986,12 +986,12 @@ BalancedBinaryTree(S: SetCategory): Exports ==
Implementation where
++ f(l,r) where l and r are the values at the immediate
++ left and right nodes.
++
- ++E T1:=BalancedBinaryTree Integer
- ++E t2:=balancedBinaryTree(4, 0)$T1
- ++E setleaves!(t2,[1,2,3,4]::List(Integer))
- ++E adder(a:Integer,b:Integer):Integer == a+b
- ++E mapUp!(t2,adder)
- ++E t2
+ ++X T1:=BalancedBinaryTree Integer
+ ++X t2:=balancedBinaryTree(4, 0)$T1
+ ++X setleaves!(t2,[1,2,3,4]::List(Integer))
+ ++X adder(a:Integer,b:Integer):Integer == a+b
+ ++X mapUp!(t2,adder)
+ ++X t2
mapUp_!: (%, %, (S,S,S,S) -> S) -> %
++ mapUp!(t,t1,f) traverses balanced binary tree t in an "endorder"
@@ -1002,12 +1002,12 @@ BalancedBinaryTree(S: SetCategory): Exports ==
Implementation where
++ corresponding nodes of a balanced binary tree t1, of identical
++ shape at t.
++
- ++E T1:=BalancedBinaryTree Integer
- ++E t2:=balancedBinaryTree(4, 0)$T1
- ++E setleaves!(t2,[1,2,3,4]::List(Integer))
- ++E adder4(i:INT,j:INT,k:INT,l:INT):INT == i+j+k+l
- ++E mapUp!(t2,t2,adder4)
- ++E t2
+ ++X T1:=BalancedBinaryTree Integer
+ ++X t2:=balancedBinaryTree(4, 0)$T1
+ ++X setleaves!(t2,[1,2,3,4]::List(Integer))
+ ++X adder4(i:INT,j:INT,k:INT,l:INT):INT == i+j+k+l
+ ++X mapUp!(t2,t2,adder4)
+ ++X t2
mapDown_!: (%,S,(S,S) -> S) -> %
++ mapDown!(t,p,f) returns t after traversing t in "preorder"
@@ -1017,12 +1017,12 @@ BalancedBinaryTree(S: SetCategory): Exports ==
Implementation where
++ mapDown!(r,q,f) are evaluated for the left and right subtrees
++ l and r of t.
++
- ++E T1:=BalancedBinaryTree Integer
- ++E t2:=balancedBinaryTree(4, 0)$T1
- ++E setleaves!(t2,[1,2,3,4]::List(Integer))
- ++E adder(i:Integer,j:Integer):Integer == i+j
- ++E mapDown!(t2,4::INT,adder)
- ++E t2
+ ++X T1:=BalancedBinaryTree Integer
+ ++X t2:=balancedBinaryTree(4, 0)$T1
+ ++X setleaves!(t2,[1,2,3,4]::List(Integer))
+ ++X adder(i:Integer,j:Integer):Integer == i+j
+ ++X mapDown!(t2,4::INT,adder)
+ ++X t2
mapDown_!: (%,S, (S,S,S) -> List S) -> %
++ mapDown!(t,p,f) returns t after traversing t in "preorder"
@@ -1034,12 +1034,12 @@ BalancedBinaryTree(S: SetCategory): Exports ==
Implementation where
++ pl and pr. Then \spad{mapDown!(l,pl,f)} and \spad{mapDown!(l,pr,f)}
++ are evaluated.
++
- ++E T1:=BalancedBinaryTree Integer
- ++E t2:=balancedBinaryTree(4, 0)$T1
- ++E setleaves!(t2,[1,2,3,4]::List(Integer))
- ++E adder3(i:Integer,j:Integer,k:Integer):List Integer == [i+j,j+k]
- ++E mapDown!(t2,4::INT,adder3)
- ++E t2
+ ++X T1:=BalancedBinaryTree Integer
+ ++X t2:=balancedBinaryTree(4, 0)$T1
+ ++X setleaves!(t2,[1,2,3,4]::List(Integer))
+ ++X adder3(i:Integer,j:Integer,k:Integer):List Integer == [i+j,j+k]
+ ++X mapDown!(t2,4::INT,adder3)
+ ++X t2
Implementation == BinaryTree(S) add
Rep := BinaryTree(S)
@@ -1112,20 +1112,20 @@ PendantTree(S: SetCategory): T == C where
ptree : S->%
++ ptree(s) is a leaf? pendant tree
++
- ++E t1:=ptree([1,2,3])
+ ++X t1:=ptree([1,2,3])
ptree:(%, %)->%
++ ptree(x,y) \undocumented
++
- ++E t1:=ptree([1,2,3])
- ++E ptree(t1,ptree([1,2,3]))
+ ++X t1:=ptree([1,2,3])
+ ++X ptree(t1,ptree([1,2,3]))
coerce:%->Tree S
++ coerce(x) \undocumented
++
- ++E t1:=ptree([1,2,3])
- ++E t2:=ptree(t1,ptree([1,2,3]))
- ++E t2::Tree List PositiveInteger
+ ++X t1:=ptree([1,2,3])
+ ++X t2:=ptree(t1,ptree([1,2,3]))
+ ++X t2::Tree List PositiveInteger
C == add
Rep := Tree S
diff --git a/src/interp/format.boot.pamphlet b/src/interp/format.boot.pamphlet
index 7dca247..de87ba6 100644
--- a/src/interp/format.boot.pamphlet
+++ b/src/interp/format.boot.pamphlet
@@ -253,7 +253,7 @@ reportOpSymbol op1 ==
\subsection{sayExample}
This function expects 2 arguments, the documentation string and
the name of the operation. It searches the documentation string for
-\verb|++E| lines. These lines are examples lines for functions.
+\verb|++X| lines. These lines are examples lines for functions.
They look like ordinary \verb|++| comments and fit into the ordinary
comment blocks. So, for example, in the plot.spad.pamphlet file we
find the following function signature:
@@ -262,34 +262,34 @@ find the following function signature:
++ plot(f,a..b) plots the function \spad{f(x)}
++ on the interval \spad{[a,b]}.
++
- ++E fp:=(t:DFLOAT):DFLOAT +-> sin(t)
- ++E plot(fp,-1.0..1.0)$PLOT
+ ++X fp:=(t:DFLOAT):DFLOAT +-> sin(t)
+ ++X plot(fp,-1.0..1.0)$PLOT
\end{verbatim}
-This function splits out and prints the lines that begin with \verb|++E|.
+This function splits out and prints the lines that begin with \verb|++X|.
A minor complication of printing the examples is that the lines have
been processed into internal compiler format. Thus the lines that read:
\begin{verbatim}
- ++E fp:=(t:DFLOAT):DFLOAT +-> sin(t)
- ++E plot(fp,-1.0..1.0)$PLOT
+ ++X fp:=(t:DFLOAT):DFLOAT +-> sin(t)
+ ++X plot(fp,-1.0..1.0)$PLOT
\end{verbatim}
are actually stored as one long line containing the example lines
\begin{verbatim}
"\\indented{1}{plot(\\spad{f},{}a..\\spad{b}) plots the function
\\spad{f(x)}} \\indented{1}{on the interval \\spad{[a,{}b]}.}
\\blankline
- \\spad{E} fp:=(t:DFLOAT):DFLOAT +-> sin(\\spad{t})
- \\spad{E} plot(\\spad{fp},{}\\spad{-1}.0..1.0)\\$PLOT"
+ \\spad{X} fp:=(t:DFLOAT):DFLOAT +-> sin(\\spad{t})
+ \\spad{X} plot(\\spad{fp},{}\\spad{-1}.0..1.0)\\$PLOT"
\end{verbatim}
-This function finds examples and strips off the prefix \verb|\\spad{E}|
+This function finds examples and strips off the prefix \verb|\\spad{X}|
from the stored form and calls cleanupLine to get rid of the other noise.
<<*>>=
sayExample(docstring,op) ==
- point := SEARCH('"{E}",docstring)
+ point := SEARCH('"{X}",docstring)
point =>
line := SUBSEQ(docstring,point+3)
- while (mark:=SEARCH('"{E}",line)) repeat
+ while (mark:=SEARCH('"{X}",line)) repeat
mark > 0 =>
PRINC cleanupLine (SUBSEQ(line,0,mark-6))
sayNewLine()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Axiom-developer] 20080824.01.tpd.patch (use ++X for examples lines),
daly <=