Re: How to get a set response interactively
Paul Singleton <[email protected]> Thu, 10 Apr 2014 11:10:26 +0100
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Organization | Jambusters Ltd |
| Message-ID | <[email protected]> |
On 10/04/2014 00:24, Richard A. O'Keefe wrote:
> Better still, create an auxiliary predicate:
>
> mount_os(OS) :-
> mount(_, path([OS|_]), _).
>
> and then call
>
> ?- setof(OS, mount_os(OS), Mounts).
NB an auxiliary predicate
* can be tested independently (informal or unit tests)
* can be documented in the usual way (encouraging,
as a bonus, consideration of what it means)
* can be debugged more easily
* is much more resilient against future changes
which introduce new variables
I'd almost recommend an auxiliary predicate whether it needs one or not...
Paul Singleton