如何压缩 Haskell 上的字符串?
How to compress a string on Haskell?
我开始学习 Haskell 中的一些命令。我刚上了一门数学本科生基础C的编程基础课。所以,如果我不能更好地解释自己,或者如果这个问题很明显,或者太复杂,或者对 Haskell 不好,我很抱歉。
我想做的事:在文本上生成一些大小为 n 的随机字符串后,压缩该字符串并计算它的字节数。
这个例子与 Mathematica 上的这个函数非常相似:https://reference.wolfram.com/language/ref/Compress.html
JuicyPixels' Codec.Picture.Saving.imageToBitmap 将产生一个 ByteString。
zlib's Codec.Compression.GZip.compress 将采用该 ByteString 并生成压缩的 ByteString。
base64-bytestring's Data.ByteString.Base64.encode 将采用压缩的 ByteString 并生成类似于 Matlab 的 Compress 的可打印 ASCII 字符串。
我开始学习 Haskell 中的一些命令。我刚上了一门数学本科生基础C的编程基础课。所以,如果我不能更好地解释自己,或者如果这个问题很明显,或者太复杂,或者对 Haskell 不好,我很抱歉。
我想做的事:在文本上生成一些大小为 n 的随机字符串后,压缩该字符串并计算它的字节数。
这个例子与 Mathematica 上的这个函数非常相似:https://reference.wolfram.com/language/ref/Compress.html
JuicyPixels' Codec.Picture.Saving.imageToBitmap 将产生一个 ByteString。 zlib's Codec.Compression.GZip.compress 将采用该 ByteString 并生成压缩的 ByteString。 base64-bytestring's Data.ByteString.Base64.encode 将采用压缩的 ByteString 并生成类似于 Matlab 的 Compress 的可打印 ASCII 字符串。