how to save a structure in gap

87 Views Asked by At

Is there a way to save a structure to a file in GAP? For example :

data:=rec();
data.Name:="random matrix";
data.Value:=RandomMat(3,4);
data.Rank:=2;

How would I save "data" to a file so it can be read from GAP at a future session? and how would I read it back in. (I don't want to save the entire workspace, just the records I want to use later).

1

There are 1 best solutions below

3
On BEST ANSWER

There is no dedicated functionality for saving a single object. Using Print (or PrintTo a file) should produce GAP-readable input, but you need to supply the assignment syntax yourself, and you will lose information caches inside objects, or use of compressed data types.

In your case, you could use

PrintTo("mydatafile","data:=",data,";\n");

so that Read("mydatafile"); would give you an object in a new session.