output file type....

14 views
Skip to first unread message

Sid Andal

unread,
Nov 24, 2021, 2:34:12 PM11/24/21
to FriCAS - computer algebra system

I have an output file opened of type union (for mixed types):

f : File Union(List Integer, String) := open("test.out", "output")
write!(f, [1,2,3,4,5,6,7,8])
write!(f, "0123456789")
close!(f)

Here's the content of test.out:

(0 1 2 3 4 5 6 7 8)

(1 . "0123456789")

The 2nd line containing the string doesn't look right. How do I print the string itself (without the prefix 1.) and without the double-quotes?

Ralf Hemmecke

unread,
Nov 24, 2021, 4:06:19 PM11/24/21
to fricas...@googlegroups.com
Why do you think it is wrong?

https://github.com/fricas/fricas/blob/master/src/algebra/files.spad#L132

Honestly, I could not judge this. The docstring for write!

http://fricas.github.io/api/FileCategory.html#l46696c6543617465676f7279-777269746521

is not very precise.

The only thing you can say is that it is not what you expected.
Just to make things clear.

OK, but that doesn't help you. I was anyway wondering why you would be
satisfied with output that looks pretty LISP like. Is this really what
you want?

Don't just work on "somehow getting some output". Try to specify exactly
what you want and how you want it. Maybe your input data comes in a
certain format from somewhere and you want you output in a certain
format for further use. So what is it?

Maybe putting together a few lines of FriCAS code and a little shell
script may better serve your purpose. However, to be able to help you,
you must be much clearer.

Ralf

PS:
I actually don't care about what write! outputs. I never had such a need
to use it. As I said before, the fricas output of
https://fricas.github.io/book.pdf was produced automatically. And since
I programmed it I know that there is not write! command in the process.

Sid Andal

unread,
Nov 24, 2021, 4:36:18 PM11/24/21
to FriCAS - computer algebra system
I was basically going according to book.pdf. I'm not aware if there are better ways to do file I/O in fricas. I have a large script that does many algebraic calculations and then outputs the result to a file. The output consists of algebraic types as well as strings of text and I don't know how to output them all together nicely! Also, I'm not familiar with SPAD.

Ralf Hemmecke

unread,
Nov 24, 2021, 6:12:22 PM11/24/21
to fricas...@googlegroups.com
> I'm not aware if there are better ways to do file I/O in fricas.

Maybe not better ways, but if you just complain and do not say what
exactly you want, I do no longer waste my time in trying to help you.

> I have a large script that does many algebraic calculations and then
> outputs the result to a file.

Sounds as everything is fine an there is no problem.

> The output consists of algebraic types as well as strings of text and
> I don't know how to output them all together nicely!
???

Ralf

Sid Andal

unread,
Nov 25, 2021, 12:14:37 PM11/25/21
to FriCAS - computer algebra system
The question was very clear and self explanatory....I asked how to output a string into a file without the leading "1." and without the double quotes.

Bill Page

unread,
Nov 25, 2021, 1:03:01 PM11/25/21
to fricas...@googlegroups.com

On Thu, Nov 25, 2021 at 12:14 PM Sid Andal <anda...@gmail.com> wrote:
The question was very clear and self explanatory....I asked how to output a string into a file without the leading "1." and without the double quotes.

(1) -> )sys cat test.input
f : TextFile := open("test.out", "output")
writeLine!(f, unparse([1,2,3,4,5,6,7,8]::InputForm))
writeLine!(f, "0123456789")
close!(f)
(1) -> )r test
f : TextFile := open("test.out", "output")
 

   (1)  "test.out"
                                                               Type: TextFile
writeLine!(f, unparse([1,2,3,4,5,6,7,8]::InputForm))
 

   (2)  "[1,2,3,4,5,6,7,8]"
                                                                 Type: String
writeLine!(f, "0123456789")
 

   (3)  "0123456789"
                                                                 Type: String
close!(f)
 

   (4)  "test.out"
                                                               Type: TextFile
(5) -> )sys cat test.out
[1,2,3,4,5,6,7,8]
0123456789
(5) -> 

Sid Andal

unread,
Nov 28, 2021, 2:25:37 PM11/28/21
to FriCAS - computer algebra system
Thanks! This is exactly that I was looking for.
Reply all
Reply to author
Forward
0 new messages