(1)可以通过 stretch 和 take 函数搭配实现:
take(x.stretch(x.count()*2), x.count())
(2)通过 bar 函数实现:
bar(x, 2, closed='right') / 2
(3)通过循环两两填充。与上述方法相比,优势是可以自己指定填充值:
x = [1,2,3,4,5,6,7,8]
re = matrix(cut(x, 2))
fillValue = 1..4
each(fill!{re}, 0..(re.cols()-1), fillValue)
re.flatten()