Serge D. Mechveliani
>
> People,
>
> there is something about the file input/output which I do not find
> in the Axiom book.
> I take the example of a function
> inpEvalOut : String -> String -> String
> which
> * takes name1, name2,
> * inputs a string str from the file name1,
> * parses str as a program P to interpret,
> interprets P, with writing the result to resStr : String,
> * outputs resStr to the file name2 and
> returns the result resStr.
>
> For example, if the file 1.txt contains the string "20 + 3",
> then the call
> inpEvalOut "1.txt" "2.txt"
>
> has the result of resStr = "23", together with the side effect of
> output of "23" to the file 2.txt.
>
> It is something like this:
>
> inpEvalOut(name1 : String, name2 : String) : String ==
>
> str := inputStringFromFile name1
> resStr := parseEvaluateWriteToString str
> outputToFile resStr name2
> return resStr
>
> (if the Axiom syntax is correct).
> There are the following questions.
> * What the Axiom library has for the above aimed functions
> inputStringFromFile, parseEvaluateWriteToString, outputToFile
> ?
For parsing and evaluation:
parse from InputForm gives parsed representation of string,
as InputForm, interpret evaluates InputForm giving you
result of type Any.
FriCAS prints values by first converting them to OutputForm,
and then using appropriate formatter on OutputForm.
You may prefer convertiong output to InputForm and
using unparse:
(2) -> fp := factor(x^2-1)
(2) (x - 1)(x + 1)
Type: Factored(Polynomial(Integer))
(3) -> fpi := fp::InputForm
(3)
(* (primeFactor (:: (+ x - 1) (Polynomial (Integer))) 1)
(primeFactor (:: (+ x 1) (Polynomial (Integer))) 1))
Type: InputForm
(4) -> unparse(fpi)$InputForm
(4)
"primeFactor((x+-1)::Polynomial(Integer),1)*primeFactor((x+1)::Polynomial(Int
eger),1)"
Type: String
> * (similar as the C standard library)
> Has it functions for opening and closing of a file?
> Do the above functions for files return the values for the success of
> a file operation? (for the user program to process these values).
>
see constructors having File in the name, in particular TextFile
> * If there are not such functions, maybe, to set
> )read and )set spool name2 into the body of the function f,
> in some way?
> First, I tried to input to the dialogue
> f(name1 : String, name2 : String) : String == )read 1.input
> .
> But Axiom reports "Improper syntax" for the position where
> ")read" starts.
>
systemCommand("set output algebra 2.txt")$MoreSystemCommands
systemCommand("read 1.input")$MoreSystemCommands
--
Waldek Hebisch
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.