Cut

Description

Example how to use cut predicate

Source: Adventure in Prolog (on-line tutorial)

Download

Program source code: cut.pl

Listing

data(one).
data(two).
data(three).
 
cut_test_a(X) :-
  data(X).
cut_test_a('last clause').
 
cut1:-cut_test_a(X), write(X), nl, fail.
 
 
cut_test_b(X) :-
  data(X),
  !.
cut_test_b('last clause').
 
cut2:-cut_test_b(X), write(X), nl, fail.
 
cut_test_c(X,Y) :-
  data(X),
  !,
  data(Y).
cut_test_c('last clause').
 
cut3:-cut_test_c(X,Y), write(X-Y), nl, fail.

Comments

pl/prolog/pllib/cut.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