# Nice to know ... setof/3 and ^/0

**URL:** <https://swi-prolog.discourse.group/t/nice-to-know-setof-3-and-0/4285>\
**Category:** Nice to know\
**Created:** [August 12, 2021, 8:42am UTC](https://swi-prolog.discourse.group/t/nice-to-know-setof-3-and-0/4285 "2021-08-12T08:42:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wisermans](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/wisermans/32/3113_2.png) [@Wisermans](https://swi-prolog.discourse.group/u/Wisermans)\
**Post date:** [August 12, 2021, 8:42am UTC](https://swi-prolog.discourse.group/t/nice-to-know-setof-3-and-0/4285/1 "2021-08-12T08:42:26Z")

</div>

An easy way to extract an ordered list from predicates:

```
myrec(1,a).
myrec(1,b).
myrec(2,b).
myrec(3,c).
myrec(2,c).

?- setof(Record, Data^myrec(Record,Data), Results).
Results = [1, 2, 3]

```

To read as: ““Find the set for all myrec, such that the record has some Data, and put the result in Results (ordered and with no duplicate).”
