# Problem with setof and findall

**URL:** <https://swi-prolog.discourse.group/t/problem-with-setof-and-findall/812>\
**Category:** Help!\
**Created:** [June 13, 2019, 9:06pm UTC](https://swi-prolog.discourse.group/t/problem-with-setof-and-findall/812 "2019-06-13T21:06:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nxiao](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@nxiao](https://swi-prolog.discourse.group/u/nxiao)\
**Post date:** [June 13, 2019, 9:06pm UTC](https://swi-prolog.discourse.group/t/problem-with-setof-and-findall/812/1 "2019-06-13T21:06:33Z")

</div>

I’m using: SWI-Prolog version - 8.1.5

I want the code to:

But what I’m getting is:

My code looks like this:

```prolog
[1] ?- findall(W, member(W, [a, b, params(c, d), d]), Ws).
Ws = [ab["a", "b", params("c", "d"), "d"].

```

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [June 13, 2019, 9:31pm UTC](https://swi-prolog.discourse.group/t/problem-with-setof-and-findall/812/2 "2019-06-13T21:31:56Z")

</div>

Your posting is missing what you want the code to do, and your “My code looks like this” seems to have a copy&paste error.

`findall/3` and `bagof/3` are the inverses of `member/2` (although things get a bit more complicated when there a universally or existentially qualified variables in the goals).  
When I ran them, I got:

```prolog
1 ?- findall(W, member(W, [a,b,params(c,d),d]), Ws).
Ws = [a, b, params(c, d), d].

2 ?- bagof(W, member(W, [a,b,params(c,d),d]), Ws).
Ws = [a, b, params(c, d), d].

```

---

<div class="post-metadata">

**Author:** ![nxiao](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@nxiao](https://swi-prolog.discourse.group/u/nxiao)\
**Post date:** [June 14, 2019, 3:05am UTC](https://swi-prolog.discourse.group/t/problem-with-setof-and-findall/812/3 "2019-06-14T03:05:21Z")

</div>

My bad. It was caused by a portray/1.

Thanks, Peter.

Nan
