Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

problem 1: prepare a Prolog predicate has_duplicates (L) which is true if list L contains duplicated elements (i.e., at least 2 copies of an element). For ex:

?- has_duplicates([a,e,b,d,s,e]).
Yes
?- has_duplicates([a,b,d,s,e]).
No
?- has_duplicates([]).
No

problem 2: prepare a Prolog predicate remove_nth (N, L1, L2) which is true if list L2 is just list L1 with its Nth element removed. If L1 does not have an Nth element then the predicate must fail. You can suppose that N is strictly greater than 0. For ex:

?- remove_nth(4,[a,e,e,d,s,e],L).
L = [a,e,e,s,e] ;
No
?- remove_nth(6,[a,b],L).
No

problem 3: Define a Prolog predicate flatten (List, FlattenedList) which asserts List is any nested list of atoms and FlattenedList is the same list with the nesting removed. The atom [] must as well be removed. Your predicate must only produce one answer. You might use the built-in predicates not, ! and append. Don’t use a helper predicate.

?- flatten([a, [[b,c],d], [[e]], [f]], X).
X = [a,b,c,d,e,f] ;
no
?- flatten([a,[[]], [[c,d],e]], X).
X = [a,c,d,e] ;
no

problem 4: Implement a two-dimensional table in Prolog. Your program will include:

a) An insert_entry predicate that takes a table, row, column and an entry and inserts the entry at the given position creating a new table.

b) A search_entry predicate that takes a table, row and column and unifies its fourth argument with entry at the indicated place of the table.

c) prepare code which creates a table and populates it with at least 2 rows and 2 columns.

problem 5: We want to make a structure which will represent a deck of cards (not essentially full). Each card has a character (between  ‘2’  to  ‘9’ and  ‘T’,  ‘J’,  ‘Q’,  ‘K’,  ‘A’) and a suit (diamonds, hearts, clubs and spades):

a) Select a representation for each card and as well for the deck of cards (it can be empty or non-empty)

b) Define an add_card predicate which takes a card and a deck and adds the card if it is not already there (that is, no duplicates) making a new deck of cards. If the card is not of a valid suit or number this predicate will simply do nothing.

c) Define a sort_deck predicate which sorts a deck of cards putting diamonds first, hearts second, clubs third and spades at the end (each suit in ascending order itself).

d) Comprise a test case in your program which creates a deck of at least 5 cards and sorts it.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M9419

Have any Question?


Related Questions in Programming Language

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As