Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write an array into a text file in maxima?

Tags:

maxima

I am relatively new to maxima. I want to know how to write an array into a text file using maxima.

like image 885
phobos Avatar asked Oct 25 '25 04:10

phobos


2 Answers

I know it's late in the game for the original post, but I'll leave this here in case someone finds it in a search.

Let A be a Lisp array, Maxima array, matrix, list, or nested list. Then:

write_data (A, "some_file.data");

Let S be an ouput stream (created by openw or opena). Then:

write_data (A, S);

Entering ?? numericalio at the input prompt, or ?? write_ or ?? read_, will show some info about this function and related ones.

like image 152
Robert Dodier Avatar answered Oct 26 '25 23:10

Robert Dodier


I've never used maxima (or even heard of it), but a little Google searching out of curiousity turned up this: http://arachnoid.com/maxima/files_functions.html

From what I can gather, you should be able to do something like this:

stringout("my_new_file.txt",values);

It says the second parameter to the stringout function can be one or more of these:

  • input: all user entries since the beginning of the session.
  • values: all user variable and array assignments.
  • functions: all user-defined functions (including functions defined within any loaded packages).
  • all: all of the above. Such a list is normally useful only for editing and extraction of useful sections.

So by passing values it should save your array assignments to file.

like image 38
Jeremy Harris Avatar answered Oct 27 '25 00:10

Jeremy Harris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!