-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
43 lines (27 loc) · 854 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from chemical import it
'''
print(it)
for i in it(range(10)).take(3).skip(2):
print(i)
a = 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
print(it(a).all(lambda x: x > 2))
print(it(a).skip(6).all(lambda x: x < 5))
print(list(it(a).skip(6)))
# def mul(state, x):
# print(state, x)
# state[0] = state[0] * x
# return state[0]
# print(list(it([1, 2, 3, 4]).scan(1, mul)))
print(it([1, 2, 3]).product())
print(it([1, 2, 3, 4, 5]).nth(1))
print(list(it(range(10)).step_by(3).skip(1).take(2)))
'''
for i in it(range(10)).step_by(2).collect(list):
print(i)
print(it(range(10)).step_by(2).collect(lambda items: {i : i for i in items}))
print(it(range(10)).step_by(2).skip(1).collect())
print(list(range(10))[2::2])
print()
print(it(range(10)).step_by(2).collect())
print(it(range(10)).step_by(2).nth(3))
print(it(range(10)).step_by(2).nth(3))