blob: bc2bdb90377b2f8509f249bc8ff0fcde2fc17b47 (
plain) (
blame)
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
44
|
(
(let config (DataSource 'config))
(let world (Configure! world config 'PureDataSource 'yt))
(let res_sink (DataSink 'result))
(let listVal (AsList (Int32 '0)))
(let listVal (Append listVal (Int32 '1)))
(let emptyList (List (ListType (DataType 'Int32))))
(let emptyStream (EmptyIterator (StreamType (DataType 'Int32))))
(let emptyOptional (Nothing (OptionalType (DataType 'Int32))))
(let notOptLambda (lambda '(x) (< x (Int32 '1))))
# Take while true: [0, 1]
(let res (TakeWhile listVal (lambda '(x) (Bool 'true))))
(let world (Write! world res_sink (Key) res '('('type))))
# Take while false: []
(let res (TakeWhile listVal (lambda '(x) (Bool 'false))))
(let world (Write! world res_sink (Key) res '('('type))))
# Take from empty list: []
(let res (TakeWhile emptyList notOptLambda))
(let world (Write! world res_sink (Key) res '('('type))))
# Take from empty stream: []
(let res (TakeWhile emptyStream notOptLambda))
(let res (Collect res))
(let world (Write! world res_sink (Key) res '('('type))))
# Take from empty optional: []
(let res (TakeWhile emptyOptional notOptLambda))
(let world (Write! world res_sink (Key) res '('('type))))
# General case: [0]
(let res (TakeWhile listVal notOptLambda))
(let world (Write! world res_sink (Key) res '('('type))))
(let world (Commit! world res_sink))
(return world)
)
|