我想在另一个流中找到匹配项并将其与当前项目结合起来。
numbers = [1, 2, 3, 4, 5]
numbers_in_char = ["2", "1", "3", "5", "4"]
textnumbers_in_stream = rx.defer(rx.from_iterable(numbers_in_char))
def exists_in_words(number, words):
return words.pipe(
op.filter(lambda w: int(w) == number),
op.map(lambda w: (number, w))
)
rx \
.from_iterable(numbers) \
.pipe(op.map(lambda number: exists_in_words(number, textnumbers_in_stream))) \
.subscribe(lambda row: print(row))
我希望打印这些:
(1,"1")
(2,"2")
(3,"3")
...
但是我有:
None
None
None
...
有人可以给我一个想法,我做错了什么?
提前谢谢了