I'm trying to print a very long list to a file using magma to make it "callable". The list is called F2, and the code I'm using to print this list to a file is the following
SetOutputFile("...");
printf "F2 := %o ;", F2;
(where, of course, ... is my file directory) however, the list in the file is always incomplete, that is, the list is cut in some part.
I have not been able to determine the causes of this issue. I tried again with two lists, F1 and F2, using the following code:
SetOutputFile("...");
printf "F1 := %o ; \n F2 := %o ;", F1, F2;
and, weirdly, F1 is printed completely while F2 is not.
I really appreciate any information you can give me. If I need to add some specifications about the system I'm using just let me know.
You are using the wrong mechanism for printing to a file in MAGMA. What you are doing is setting a file for the normal MAGMA buffer to output to; this means what would normally be printed to the screen is instead routed to a file. I'm guessing your intention is to write this MAGMA object to a file so you can read it in later in new MAGMA sessions. In this case, you want to use the
PrintFile
command:It can be a bit tricky to get MAGMA to read back in these objects from the file in an efficient way; what I tend to do is to save a single object to a file, using
PrintFileMagma
, which makes sure this is written to the file in the proper MAGMA format:Then I have a custom function defined in my startup file to read these back in:
Then in a new MAGMA session I can simply type
to import the desired object.
Edit: It was mentioned that MAGMA doesn't write some objects like
AssociativeArray
properly in Magma mode.One workaround for this particular case is to save the AssociativeArray as a list of tuples,
and then convert back into an associative array when you load using.. well it seems a for loop is the only way to initialize an associative array.