|
|
last edited 17 years ago by page |
1 | ||
Editor: page
Time: 2007/11/12 23:41:29 GMT-8 |
||
Note: transferred from axiom-developer.org |
changed: - This package provides operations that all take a filename and return an axiom structure which is supposed to be in some standard notation in this file. Geared towards polymake. Needs 'StringConversions' \begin{axiom} )lib STRCNV \end{axiom} \begin{axiom} )abbrev package READFILE ReadFile ReadFile(): Exports == Implementation where Exports == with getBoolean: FileName -> Boolean getInteger: FileName -> Integer getFraction: FileName -> Fraction Integer getListInteger: FileName -> List Integer getListFraction: FileName -> List Fraction Integer getVectorInteger: FileName -> Vector Integer getVectorFraction: FileName -> Vector Fraction Integer getSetInteger: FileName -> Set Integer getMatrixInteger: FileName -> Matrix Integer getMatrixFraction: FileName -> Matrix Fraction Integer getListSetInteger: FileName -> List Set Integer Implementation == add getBoolean polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile (r="1") getInteger polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile coerce(r)$StringConversions getFraction polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile coerce(r)$StringConversions getListInteger polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile coerce(r)$StringConversions getListFraction polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile coerce(r)$StringConversions getVectorInteger polytmpfile == vector(getListInteger polytmpfile)$Vector(Integer) getVectorFraction polytmpfile == vector(getListFraction polytmpfile)$Vector(Fraction Integer) getSetInteger polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile coerce(r)$StringConversions getMatrixInteger polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile m: List List Integer := [] r: String while not endOfFile?(f) repeat r := read!(f)$TextFile if not empty? r then m := cons(coerce(r)$StringConversions, m) close!(f)$TextFile matrix(reverse m)$Matrix(Integer) getMatrixFraction polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile m: List List Fraction Integer := [] r: String while not endOfFile?(f) repeat r := read!(f)$TextFile if not empty? r then m := cons(coerce(r)$StringConversions, m) close!(f)$TextFile matrix(reverse m)$Matrix(Fraction Integer) getListSetInteger polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile m: List Set Integer := [] r: String while not endOfFile?(f) repeat r := read!(f)$TextFile if not empty? r then m := cons(coerce(r)$StringConversions, m) close!(f)$TextFile reverse m \end{axiom}
This package provides operations that all take a filename and return an axiom structure which is supposed to be in some standard notation in this file. Geared towards polymake. Needs StringConversions
(1) -> )lib STRCNV
>> System error: The value 1954 is not of type LIST
)abbrev package READFILE ReadFile ReadFile(): Exports == Implementation where Exports == with
getBoolean: FileName -> Boolean
getInteger: FileName -> Integer
getFraction: FileName -> Fraction Integer
getListInteger: FileName -> List Integer
getListFraction: FileName -> List Fraction Integer
getVectorInteger: FileName -> Vector Integer
getVectorFraction: FileName -> Vector Fraction Integer
getSetInteger: FileName -> Set Integer
getMatrixInteger: FileName -> Matrix Integer
getMatrixFraction: FileName -> Matrix Fraction Integer
getListSetInteger: FileName -> List Set Integer
Implementation == add
getBoolean polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile
(r="1")
getInteger polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile
coerce(r)$StringConversions
getFraction polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile
coerce(r)$StringConversions
getListInteger polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile coerce(r)$StringConversions
getListFraction polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile coerce(r)$StringConversions
getVectorInteger polytmpfile == vector(getListInteger polytmpfile)$Vector(Integer)
getVectorFraction polytmpfile == vector(getListFraction polytmpfile)$Vector(Fraction Integer)
getSetInteger polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile r:String := read!(f)$TextFile close!(f)$TextFile coerce(r)$StringConversions
getMatrixInteger polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile m: List List Integer := [] r: String while not endOfFile?(f) repeat r := read!(f)$TextFile if not empty? r then m := cons(coerce(r)$StringConversions,m)
close!(f)$TextFile matrix(reverse m)$Matrix(Integer)
getMatrixFraction polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile m: List List Fraction Integer := [] r: String while not endOfFile?(f) repeat r := read!(f)$TextFile if not empty? r then m := cons(coerce(r)$StringConversions,m)
close!(f)$TextFile matrix(reverse m)$Matrix(Fraction Integer)
getListSetInteger polytmpfile == f := open(polytmpfile)$TextFile read!(f)$TextFile m: List Set Integer := [] r: String while not endOfFile?(f) repeat r := read!(f)$TextFile if not empty? r then m := cons(coerce(r)$StringConversions,m)
close!(f)$TextFile reverse m
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7130290122364710480-25px.002.spad using old system compiler. READFILE abbreviates package ReadFile ------------------------------------------------------------------------ initializing NRLIB READFILE for ReadFile compiling into NRLIB READFILE compiling exported getBoolean : FileName -> Boolean Time: 0.01 SEC.
compiling exported getInteger : FileName -> Integer ****** comp fails at level 3 with expression: ****** error in function getInteger
(SEQ (|:=| |f| ((|Sel| (|TextFile|) |open|) |polytmpfile|)) ((|Sel| (|TextFile|) |read!|) |f|) (|:=| (|:| |r| (|String|)) ((|Sel| (|TextFile|) |read!|) |f|)) ((|Sel| (|TextFile|) |close!|) |f|) (|exit| 1 | << | ((|Sel| |StringConversions| |coerce|) |r|) | >> |)) ****** level 3 ****** x:= ((Sel StringConversions coerce) r) m:= (Integer) f:= ((((|r| # #) (|f| #) (|polytmpfile| # #) (|getListSetInteger| #) ...)))
>> Apparent user error: StringConversions is an unknown mode