File: 015_list_comprehension.txtar

package info (click to toggle)
golang-github-cue-lang-cue 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,644 kB
  • sloc: makefile: 20; sh: 15
file content (115 lines) | stat: -rw-r--r-- 1,517 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#name: list comprehension
#evalFull
-- in.cue --
a: [for k, v in b if k < "d" if v > b.a {k}]
b: {
	a: 1
	b: 2
	c: 3
	d: 4
}
c: [for _, x in b for _, y in b if x < y {x}]
d: [for x, _ in a {x}]
-- out/def --
a: ["b", "c"]
b: {
	a: 1
	b: 2
	c: 3
	d: 4
}
c: [1, 1, 1, 2, 2, 3]
d: [0, 1]
-- out/export --
a: ["b", "c"]
b: {
	a: 1
	b: 2
	c: 3
	d: 4
}
c: [1, 1, 1, 2, 2, 3]
d: [0, 1]
-- out/yaml --
a:
- b
- c
b:
  a: 1
  b: 2
  c: 3
  d: 4
c:
- 1
- 1
- 1
- 2
- 2
- 3
d:
- 0
- 1
-- out/json --
{"a":["b","c"],"b":{"a":1,"b":2,"c":3,"d":4},"c":[1,1,1,2,2,3],"d":[0,1]}
-- out/legacy-debug --
<0>{a: ["b","c"], b: <1>{a: 1, b: 2, c: 3, d: 4}, c: [1,1,1,2,2,3], d: [0,1]}
-- out/compile --
--- in.cue
{
  a: [
    for k, v in 〈1;b〉 if (〈0;k〉 < "d") if (〈0;v〉 > 〈2;b〉.a) {
      〈1;k〉
    },
  ]
  b: {
    a: 1
    b: 2
    c: 3
    d: 4
  }
  c: [
    for _, x in 〈1;b〉 for _, y in 〈2;b〉 if (〈1;x〉 < 〈0;y〉) {
      〈2;x〉
    },
  ]
  d: [
    for x, _ in 〈1;a〉 {
      〈1;x〉
    },
  ]
}
-- out/eval/stats --
Leaks:  0
Freed:  19
Reused: 12
Allocs: 7
Retain: 10

Unifications: 19
Conjuncts:    36
Disjuncts:    23
-- out/eval --
(struct){
  a: (#list){
    0: (string){ "b" }
    1: (string){ "c" }
  }
  b: (struct){
    a: (int){ 1 }
    b: (int){ 2 }
    c: (int){ 3 }
    d: (int){ 4 }
  }
  c: (#list){
    0: (int){ 1 }
    1: (int){ 1 }
    2: (int){ 1 }
    3: (int){ 2 }
    4: (int){ 2 }
    5: (int){ 3 }
  }
  d: (#list){
    0: (int){ 0 }
    1: (int){ 1 }
  }
}