# Listing example: use case for new feature in 8.3.5

**URL:** <https://swi-prolog.discourse.group/t/listing-example-use-case-for-new-feature-in-8-3-5/2712>\
**Category:** Nice to know\
**Created:** [July 28, 2020, 7:36pm UTC](https://swi-prolog.discourse.group/t/listing-example-use-case-for-new-feature-in-8-3-5/2712 "2020-07-28T19:36:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![swi](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@swi](https://swi-prolog.discourse.group/u/swi)\
**Post date:** [July 28, 2020, 7:36pm UTC](https://swi-prolog.discourse.group/t/listing-example-use-case-for-new-feature-in-8-3-5/2712/1 "2020-07-28T19:36:44Z")

</div>

listing/1 in versions 8.3.5 and forward now properly support partially ground heads, showing only the relevant clauses. Eric asked for an example on how this would be useful, and this post shows one useful scenario.

Suppose you have a large database with millions of products and thousands of categories of products. But products are only available if their corresponding warehouse is open.

Something like this:

```prolog
product(ribeye,meat,33.33,barcode1) :- warehouse(east,open).
product(pork,meat,33.33,barcode2) :- warehouse(east,open).
product(lentils,grain,12.12,barcode3) :- warehouse(west,open).
product(rice,grain,12.12,barcode4) :- warehouse(west,open).
product(black_beans,grain,12.12,barcode5) :- warehouse(west,open).
product(carrots,vegetable,13.13,barcode6) :- warehouse(south,open).
product(lettuce,vegetable,13.13,barcode7) :- warehouse(south,open).
product(peas,vegetable,13.13,barcode8) :- warehouse(south,open).

```

Suppose you just want to look at the clauses for products of type `grain`, to see the dependencies on warehouses, then you can do:

```prolog
1 ?- listing(product(_,grain,_,_)).
product(lentils, grain, 12.12, barcode3) :-
    warehouse(west, open).
product(rice, grain, 12.12, barcode4) :-
    warehouse(west, open).
product(black_beans, grain, 12.12, barcode5) :-
    warehouse(west, open).

```

and this will show you the logical dependencies for products of type `grain`; of course this can be easily programmed, but it is nice to have it of-the-shelf in listing/1. As you can see this would be useful if you have thousands of categories.
