9.41 LibraryΒΆ
The Library domain provides a simple way to store FriCAS values in a file. This domain is similar to KeyedAccessFile but fewer declarations are needed and items of different types can be saved together in the same file.
To create a library, you supply a file name.
stuff := library "/tmp/Neat.stuff"
“/tmp/Neat.stuff” |
Type: Library
Now values can be saved by key in the file. The keys should be mnemonic, just as the field names are for records. They can be given either as strings or symbols.
stuff.int := 32^2
1024 |
Type: PositiveInteger
stuff."poly" := x^2 + 1
x2+1 |
Type: Polynomial Integer
stuff.str := "Hello"
“Hello” |
Type: String
You obtain the set of available keys using the keyskeysLibrary operation.
keys stuff
[“str”,”poly”,”int”] |
Type: List String
You extract values by giving the desired key in this way.
stuff.poly
x2+1 |
Type: Polynomial Integer
stuff("poly")
x2+1 |
Type: Polynomial Integer
When the file is no longer needed, you should remove it from the file system.
)system rm -rf /tmp/Neat.stuff
For more information on related topics, see FileXmpPage , TextFileXmpPage , and KeyedAccessFileXmpPage .