窗口状态
我有一个可观察到的数字[1,3,3,5,2,4,1,3]
,并希望通过两个部门的剩余部分组对其进行窗口。因此,可观察到的结果将是[[1,3,5],[2,4],[1,3]]
。我该怎么做?
I have an observable of numbers [1, 3, 5, 2, 4, 1, 3]
and want to window it by groups of same remainder of the division by two. So, resulting observable of observables will be [[1, 3, 5], [2, 4], [1, 3]]
. How can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下片段可以产生您想要的结果,尽管我不确定您想实现什么目标。
降低
将在最后一个子阵列中添加数字,直到其中一个与其他结果除以两个相同的结果。地图
将子阵列的数组转换为可观察到的数组The below snippet can produce the results you want, although I'm not sure what you are trying to achieve with this.
The
reduce
will add numbers to the last subarray, until one of them does not have the same result with the others when divided by two.The
map
converts the array of subarrays to array of observablesworking example