AI 08226 Prolog (PROgramming in LOGic) - Department of ...
AI 08226 Prolog (PROgramming in LOGic) - Department of ...
AI 08226 Prolog (PROgramming in LOGic) - Department of ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Variation 2 on Frequency with Cut (!)<br />
121<br />
frequency(_term, [ ], 0).<br />
frequency(Item, [ Item | Rest ], N):-<br />
!, frequency(Item, Rest, N1),<br />
N is N1 +1.<br />
frequency(Item, [ _term | Rest ], N):-<br />
frequency(Item, Rest, N).<br />
- frequency(a,[a, b, a, c], N).<br />
N = 2 ;<br />
No<br />
- frequency(A,[a, b, a, c], N).<br />
<br />
<br />
A = a N = 2 ;<br />
No