在raku中是否有类似于R-lang列绑定或rowbind的东西。R-lang
例如:
my @matrix = ^100 .rotor(10);
my @cbind = cbind( @matrix [*;1..2].rotor(2) , @matrix [*;3..4].rotor(2) )
my @rbind = rbind ( @matrix [1..2;*].rotor(10) , @matrix [3..4;*].rotor(10) )发布于 2020-01-11 07:55:38
rbind很简单:
my @one = <a b c d>.rotor(2);
my @two = <e f g h>.rotor(2);
say @one.append: @two;更新:编辑感谢评论。
如果订单没有那么重要,那么您可以只使用∪,它就会变成一个集合。
cbind有点棘手,但可行:
say (@one Z @two).map( { @_.map: |* } )Z是zip运算符,它将插入第一个列表和第二个列表的元素。但是,嵌套列表太多了,所以我们需要在这里将内部列表扁平化:{ @_.map: |* }。那将输出
((a b e f) (c d g h))https://stackoverflow.com/questions/59691841
复制相似问题