cue-lang / docs-and-content

A place to discuss, plan, and track documentation on cuelang.org
6 stars 1 forks source link

docs/howto: reuse a comprehension's logic in multiple places #173

Open jpluscplusm opened 4 months ago

jpluscplusm commented 4 months ago

A user asked:

Is there any way to reuse a list comprehension across similar objects?

foo: [...#Thing]
bar: [...#Thing]

baz: [ for x in foo { complex logic } }
qux: [ for x in bar { identical logic to foo } }

They were pointed towards the Cuetorials "function pattern" page (https://cuetorials.com/patterns/functions/), which resolved their issue

Separately from having coverage of more general content such as that page, we should address the specific question in a howto.