Changes http://page.axiom-developer.org/zope/mathaction/StringConversions/diff -- Here is a package that converts strings to numbers. It is only to be considered as a starting point. There is no error checking, it is probably slow and certainly buggy...
\begin{axiom} )abbrev package STRCNV StringConversions StringConversions(): Exports == Implementation where Exports == with coerce: String -> Integer coerce: String -> Fraction Integer coerce: String -> List Fraction Integer coerce: String -> List Integer coerce: String -> Set Integer Implementation == add sexfloat:SExpression:=convert(coerce("Float")@Symbol)$SExpression coerce(s: String): Fraction Integer == if not NUMBERP(READ_-FROM_-STRING(s)$Lisp)$Lisp then error "coerce: String -> Fraction Integer: not a number" else sex := interpret(packageTran(ncParseFromString(s)$Lisp)$Lisp)$Lisp if (car car sex = sexfloat) then retract((cdr cdr sex) pretend Float)@Fraction(Integer) else if integer?(cdr sex) then ((cdr sex) pretend Integer)::Fraction Integer else (cdr cdr sex) pretend Fraction Integer coerce(s: String): Integer == PARSE_-INTEGER(s)$Lisp coerce(r: String): List Fraction Integer == map(coerce #1, split(r, char(" "))$String)_ $FiniteLinearAggregateFunctions2(String, List String, Fraction Integer, _ List Fraction Integer) coerce(r: String): List Integer == map(coerce(#1), split(r, char(" "))$String)_ $FiniteLinearAggregateFunctions2(String, List String, Integer, _ List Integer) coerce(r: String): Set Integer == s: String := delete(delete(r, #r), 1) brace(map(PARSE_-INTEGER(#1)$Lisp, split(s, char(" "))$String)_ $FiniteLinearAggregateFunctions2(String, List String, Integer, _ List Integer))$Set(Integer) \end{axiom} Let's try it: \begin{axiom} coerce("123.12")@FRAC INT \end{axiom} -- forwarded from http://page.axiom-developer.org/zope/mathaction/[EMAIL PROTECTED] _______________________________________________ Axiom-developer mailing list Axiom-developer@nongnu.org http://lists.nongnu.org/mailman/listinfo/axiom-developer