🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.prolog
Article #657

Re: miscellany re income tax planning system

#657
From: Prof. John Hughes
Date: Mon, 02 Jun 1986 20:33
19 lines
1231 bytes
>> From: dave@lsuc.UUCP
>> Subject: miscellany re income tax planning system
>> ...
>> Third, I'm currently wrestling with the task of generating,
>> for a list, every list which is a subset of that list. Thus,
>> for [a,b,c,d], I want findall to be able to find each of
>> [a,b] [a,c] [a,d] [a,b,c] [a,b,d] [a,c,d] [b,c] [b,d] [b,c,d] [c,d]. 
>

This should do the trick:

included(Subset,Set) is true if Subset is a subset of Set

included([],Set).
included([X|Subset],Set):-append(_,[X|Rest],Set),included(Subset,Rest).

It only includes subsets whose elements are in the same order as in the
original list.
Technical Details
Message-ID: <578@glasgow.glasgow.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!seismo!mcvax!ukc!kcl-cs!glasgow!rjmh
References: <1219@lsuc.UUCP> <164@cui.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!seismo!mcvax!ukc!kcl-cs!glasgow!rjmh
From: rjmh@glasgow.glasgow.UUCP (Prof. John Hughes)
Newsgroups: net.lang.prolog
Subject: Re: miscellany re income tax planning system
Message-ID: <578@glasgow.glasgow.UUCP>
Date: Mon, 2-Jun-86 16:33:31 EDT
Article-I.D.: glasgow.578
Posted: Mon Jun  2 16:33:31 1986
Date-Received: Thu, 5-Jun-86 07:32:08 EDT
References: <1219@lsuc.UUCP> <164@cui.UUCP>
Reply-To: rjmh@glasgow.UUCP (Prof. John Hughes)
Organization: Comp Sci Dept, Glasgow Univ, Scotland
Lines: 19