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).
There is no dedicated functionality for saving a single object. Using
Print(orPrintToa 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
so that
Read("mydatafile");would give you an object in a new session.