List divide

Description

Example how to divide two lists, in first there are elements lesser then set value

Source: PROLOG str. 46 Wydawnictwo PLJ Warszawa 1991 ISBN 83-85190-63-5

Download

Program source code: list_divide.pl

Listing

dziel(D, [G|O], [G|L1], L2) :- G < D, dziel(D, O, L1, L2).
dziel(D, [G|O], L1, [G|L2]) :- G > D, dziel(D, O, L1, L2).
dziel(_, [], [], []).
 
test :- dziel(7, [1, 9, 4, 2, 12], L1, L2).

Comments

pl/prolog/pllib/list_divide.txt · ostatnio zmienione: 2019/06/27 15:50 (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