Presentation is loading. Please wait.

Presentation is loading. Please wait.

CA 208 Logic Ex9 Define the following list processing predicates in Prolog: member(X,L) % if X is a member of list L last_member(X,L) %

Similar presentations


Presentation on theme: "CA 208 Logic Ex9 Define the following list processing predicates in Prolog: member(X,L) % if X is a member of list L last_member(X,L) %"— Presentation transcript:

1 CA 208 Logic Ex9 Define the following list processing predicates in Prolog: member(X,L) % if X is a member of list L last_member(X,L) % if X is the last member of list L last_two_members(X,Y,L) % if X and Y are the last two members of list L odd_list(L) % if L has odd number of elements even_list(L) % if L has even number of elements insert(X,L1,L2) % if list L2 is list L1 with X inserted delete(X,L1,L2) % if list L2 is L1 with X deleted conc(L1,L2,L) % if list L is the concatenation of L1 with L2 reverse(L1,L2) % if list L2 is the reverse of L1

2 CA 208 Logic Ex9 Define a “waffle”-machine in Prolog as a Finite-State Automaton that accepts/generates the infinite language (coded as Prolog lists): [ ] [b,l,a,h] [b,l,a,h,b,l,a,h] [b,l,a,h,b,l,a,h,b,l,a,h, ....]


Download ppt "CA 208 Logic Ex9 Define the following list processing predicates in Prolog: member(X,L) % if X is a member of list L last_member(X,L) %"

Similar presentations


Ads by Google