erg/tests/should_ok/use_itertools.er
Shunsuke Shibayama 7975935721 fix: typo
2023-11-25 13:17:25 +09:00

26 lines
564 B
Python

itertools = pyimport "itertools"
g = itertools.groupby([1, 2, 3, 3, 4, 5], i -> i > 2)
for! g, ((b, it),) =>
print! b, it
if b, do:
assert all(map(i -> i >= 3, it))
ts = itertools.tee([1, 2, 3, 4, 5], 2)
for! ts, (t: itertools.Tee,) =>
print! t
combs = itertools.combinations([1, 2, 3], 2)
for! combs, (comb,) =>
print! comb[0] + 1
#[
# pairwise is introduced in Python 3.10
pair = itertools.pairwise([1, 2, 3])
for! pair, ((l, r),) =>
print! l, r
]#
chain = itertools.chain([1, 2, 3], [4, 5])
for! chain, (i,) =>
print! i + 1