# How to iterate over the contraints returned by get\_attrs/2?

**URL:** <https://swi-prolog.discourse.group/t/how-to-iterate-over-the-contraints-returned-by-get-attrs-2/3493>\
**Category:** Help!\
**Created:** [January 14, 2021, 1:37am UTC](https://swi-prolog.discourse.group/t/how-to-iterate-over-the-contraints-returned-by-get-attrs-2/3493 "2021-01-14T01:37:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericzinda](https://avatars.discourse-cdn.com/v4/letter/e/b3f665/32.png) [@ericzinda](https://swi-prolog.discourse.group/u/ericzinda)\
**Post date:** [January 14, 2021, 1:37am UTC](https://swi-prolog.discourse.group/t/how-to-iterate-over-the-contraints-returned-by-get-attrs-2/3493/1 "2021-01-14T01:37:33Z")

</div>

I’m playing around with constraints but am stuck on how to iterate through the attributes assigned to a variable. The second argument of get\_attrs/2 won’t unify with a term of the form `att(A, B, C)`:

```prolog
:- module(noun, [noun/2]).

noun(TypeName, X) :-
    var(X),
    !,
    put_attr(X, noun, TypeName).

resolveConstraints(Variable, Value) :-
    % Docs say that second argument returns something in the form: 
    % att(module, value, More)
    get_attrs(Variable, Attrs),
    writeln(Attrs),
    % This fails...
    Attrs = att(Module, Value, []).

?- noun("rock", X), resolveConstraints(X, a).
att(noun,rock,[])
false.

```

What am I missing?

---

<div class="post-metadata">

**Author:** ![ridgeworks](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/ridgeworks/32/886_2.png) [@ridgeworks](https://swi-prolog.discourse.group/u/ridgeworks)\
**Post date:** [January 14, 2021, 2:50am UTC](https://swi-prolog.discourse.group/t/how-to-iterate-over-the-contraints-returned-by-get-attrs-2/3493/2 "2021-01-14T02:50:49Z")

</div>

I think it fails because argument `Value=a` while att `Value=rock`, i.e., simple unification failure.

---

<div class="post-metadata">

**Author:** ![ericzinda](https://avatars.discourse-cdn.com/v4/letter/e/b3f665/32.png) [@ericzinda](https://swi-prolog.discourse.group/u/ericzinda)\
**Post date:** [January 14, 2021, 2:54am UTC](https://swi-prolog.discourse.group/t/how-to-iterate-over-the-contraints-returned-by-get-attrs-2/3493/3 "2021-01-14T02:54:51Z")

</div>

Oh geez 🤦‍♂️. I suspected it was something dumb. I meant to name the head variable something else…Thanks…
