blob: 835f7040ac2eada3df65f85ae8904c888f1c81ec [file] [log] [blame] [view]
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +01001[TOC](Readme.md) [Prev](interpolfield.md) [Next](fieldcomp.md)
2
Marcel van Lohuizenaf0932f2019-01-11 13:03:56 +01003_Expressions_
4
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +01005# List Comprehensions
6
7Lists can be created with list comprehensions.
8
9The example shows the use of `for` loops and `if` guards.
10
11
12<!-- CUE editor -->
13```
14[ x*x for x in items if x rem 2 == 0]
15
16items: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
17```
18
19<!-- result -->
20```
21[4, 16, 36, 64]
22```