1 ## our_shell: ysh
2
3 #### Standalone generator expression
4 var x = (i+1 for i in 1:3)
5 # This is NOT a list. TODO: This test is overspecified.
6 pp cell x | grep -o '<generator'
7 write status=$?
8 ## status: 2
9 ## STDOUT:
10 ## END
11
12
13
14 #### List comprehension (deferred)
15 shopt -s oil:all
16
17 var n = [i*2 for i in range(5)]
18 write --sep ' ' @n
19
20 # TODO: Test this
21 #var n = [i*2 for i,j in range(5)]
22
23 var even = [i*2 for i in range(5) if i % 2 === 0]
24 write --sep ' ' @even
25 ## status: 2
26 ## STDOUT:
27 ## END
28
29
30 #### Lambda not implemented
31 const f = |x| x + 1
32
33 ## status: 2
34 ## STDOUT:
35 ## END
36
37 #### Anonymous function expression not implemented (Tea)
38
39 # Note: this results in a expr.Lambda node. But it's not parsed.
40
41 const f = func(x) {
42 myfunc(x)
43 return x + 1
44 }
45
46 ## status: 2
47 ## STDOUT:
48 ## END