Skip to content

Iteration produces unexpected number of elements #439

Answered by srenatus
fardin01 asked this question in OPA and Rego
Discussion options

You must be logged in to vote

I believe the misunderstanding might be in the meaning of ; in

r := required[_]
missing := r; not r in provided

It does not constitute a restriction or WHERE-clause, or the RHS of a comprehension. It merely is the same as a line-break. So if you look at it like that

r := required[_]
missing := r
not r in provided

it would make sense that missing has the same number of elements as some element of required. Try adding a print(missing) and you'll find that missing is a string, "repository, for which count() returns the number of characters, 10.

I believe you might be looking for a set comprehension here, like

missing := { r | r := required[_]; not r in provided }

or, equivalently,

missing :=

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fardin01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants