Joey123456
Programmer
Hey guys i have some prolog work for a class im taking and it must be handed in in 3 days. I was wondering if someone could please work them out for me. Theyre not hard for pros. Please, many thanks to whoever helps me out
1.Write clauses for the following list handling rules:
a.insert(Element,OldList,NewList) which inserts Element in the OldList to produce the NewList.
e.g. insert(8,[1,2,3],NL) binds NL to [8,1,2,3]
b.right(List,Element) which binds Element to the rightmost member within the List.
e.g. right([charlie, joey, malcolm, mary],R) binds R to ‘mary’
3.Write recursive clauses for the following predicates:
3a.deduct(List_of_Integers, Number, Result) which binds Result to the value of the Number after that each element within the List_of_Integers are deducted from it.
3b. display_items(List_of_Items) which displays a sequence of the items within the List_of_Items from left to right.
3c.push(Item, List, Stack) which binds Stack to List with the Item entered at its head.
1.Write clauses for the following list handling rules:
a.insert(Element,OldList,NewList) which inserts Element in the OldList to produce the NewList.
e.g. insert(8,[1,2,3],NL) binds NL to [8,1,2,3]
b.right(List,Element) which binds Element to the rightmost member within the List.
e.g. right([charlie, joey, malcolm, mary],R) binds R to ‘mary’
3.Write recursive clauses for the following predicates:
3a.deduct(List_of_Integers, Number, Result) which binds Result to the value of the Number after that each element within the List_of_Integers are deducted from it.
3b. display_items(List_of_Items) which displays a sequence of the items within the List_of_Items from left to right.
3c.push(Item, List, Stack) which binds Stack to List with the Item entered at its head.