Combinations without repeated

Description

Program calculates combinations without repeated elements.

Source: Guide to Prolog Programming (on-line tutorial)

Download

Program source code: combinations_without_repeated.pl

Listing

comb2(_,[]).
comb2([X|T],[X|Comb]):-comb2(T,Comb).
comb2([_|T],[X|Comb]):-comb2(T,[X|Comb]).
 
 
% use ?-comb2([1,2,3,4],[X,Y]) to generate combinations with two elements.

Comments

pl/prolog/pllib/combinations_without_repeated.txt · ostatnio zmienione: 2017/07/17 08:08 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0