compress a byte sequence
ByteArray or list of integers
(optional) equation of the form format = value
format = one of bzip2, gzip, zip, or zlib
This option allows a compression format to be specified explicitly. Options are bzip2, gzip, zip, or zlib. The default is zlib.
The Compress(A) command takes the given byte array or list and compresses it into a lossless, more compact format. The return value is a ByteArray.
If A is a list, its contents must be integers between -128 and 127.
Generate a ByteArray of number-theoretic data and compress it.
OmegaArray ≔ Array⁡1..105,NumberTheory:-NumberOfPrimeFactors,datatype=integer1
CompressedOmegaArray ≔ ArrayTools:-Compress⁡OmegaArray
Compare the size of the original with the compressed result.
Generate random data from a discrete uniform statistical distribution between -10 and 10 and compress it with zip format.
data ≔ Statistics:-Sample⁡DiscreteUniform⁡−10,10,1000000
original ≔ convert⁡data,ByteArray
compressed ≔ ArrayTools:-Compress⁡original
Compute the compression ratio for this example.
Convert a string to a ByteArray and compress it using gzip.
PaulCliffordText ≔ It was a dark and stormy night; the rain fell in torrents - except at occasional intervals, when it was checked by a violent gust of wind which swept up the streets (for it is in London that our scene lies), rattling along the housetops, and fiercely agitating the scanty flame of the lamps that struggled against the darkness.:
original ≔ StringTools:-ToByteArray⁡PaulCliffordText
compressed ≔ ArrayTools:-Compress⁡original,format=gzip
The ArrayTools[Compress] command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
The ArrayTools[Compress] command was updated in Maple 2018.
The format option was updated in Maple 2018.
Download Help Document
What kind of issue would you like to report? (Optional)