blob: 526a29a287a0afa4307c0451c2e53ffa60904030 [file] [log] [blame]
cue eval listcomp.cue
cmp stdout expect-stdout-cue
-- frontmatter.toml --
title = "List Comprehensions"
description = ""
-- text.md --
Lists can be created with list comprehensions.
The example shows the use of `for` loops and `if` guards.
-- listcomp.cue --
[ for x in #items if x rem 2 == 0 { x*x } ]
#items: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
-- expect-stdout-cue --
[4, 16, 36, 64]