(这是受到标记为重复的另一个问题的启发.我认为这是一个有趣的问题,尽管也许组合学有一个简单的解决方案,我对此非常无知.)
对于长度为vector的向量n,其中n mod 2为零,找到将向量的所有元素分成对的所有可能方法,无需替换,顺序无关紧要.
例如,对于矢量c(1,2,3,4):
list(c(1,2), c(3,4))
list(c(1,3), c(2,4))
list(c(1,4), c(2,3))
Run Code Online (Sandbox Code Playgroud)
我的方法如下(对于新手代码提前道歉):
# write a function that recursively breaks down a list of unique pairs (generated with combn). The natural ordering produced by combn means that for the first pass through, we take as the starting pair, all pairings with element 1 of the vector with all other elements. After that has been allocated, we iterate through the first p/2 pairs …Run Code Online (Sandbox Code Playgroud) 我正在尝试下载一个html页面,然后使用Racket在其上运行一个正则表达式.这适用于某些页面但不适用于其他页面.我最终解决了这个问题是因为有些页面被gzip压缩并发出HTTP GET请求,get-pure-port提供了gzip压缩页面,这当然看起来像乱码.
我的问题:有没有办法在球拍中解压缩页面,以便我可以运行正则表达式?
谢谢.