Questions: 9

Answers by our Experts: 9

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

write a prolog code that accepts input of CGPA from user and determine the level of that CGPA
I have to create a heuristic algorithm where it searches through a list of places and determines the best way to navigate from a - b by the shortest distance sorting the list into order of place & distance and displaying that list without duplicates.

I have already wrote some Prolog code where it displays the place and distance but now I need to remove the duplicates. Can anyone help?
https://www.dropbox.com/s/wptinvfbg2nucoc/Assignment01.pdf
% Process guess takes a list of codes representing the answer, a list of codes representing the current
% "display phrase" with blanks in it, and the code of the letter that was just guessed. If the guess
% was right, call substitute to put the letter in the display phrase and check for a win. Otherwise, just
% get another guess from the user.

processGuess(AnsList,BlankList,GuessName, CountFailed):-
member(GuessName,AnsList),
!,
write('Correct!'),
nl,
substitute(AnsList, BlankList, GuessName, NewBlanks),
checkWin(AnsList,NewBlanks, CountFailed).

processGuess(AnsList, BlankList, _, CountFailed) :-
( CountFailed == 5
-> format('Sorry, game over. You didn\'t guess (~s)~n', [AnsList])
; write('Wrong Try Again!'),
nl,
CountFailed1 is CountFailed + 1,
getGuess(AnsList, BlankList, CountFailed1)
).
The main idea is to make a list where i will put all the wrong letters the user gave and check it everytime he gives another wrong letter
The objective of this project is to build a Prolog program that can transform
Well-formed formulas (fbf) of a first order logical language to normal form (conjunctive
cnf or normal form).

To properly handle the existential variables we introduce a new rewrite rules,
Skolemizzazione said:

exist(X, p(X)) -> p(sk00042)

Note how sk00042 'and a constant and not variable. Note also that this operation 'and realt'a
pi'u complicated in the presence of variables universally quantified.

every(Y, exist(X, p(X, Y))) -> every(Y, p(sf666(Y), Y))

A variable existential can be replaced by a function (called Skolem) which is applied
variables pi'u universal "external".

You'll need the following code to manage the operation of Skolemization:

skolem_variable(V, SK) :- var(V), gensym(skv, SK).
skolem_function([], SF) :- skolem_var(_, SF).
skolem_function([A | ARGS], SF) :-
gensym(skf, SF_op),
SF =.. [SF_op, A | ARGS].
1. Using Prolog as the programming language for LOGIC, construct the relevant command to do the following tasks:-


a. Prolog Lists - A list is either empty or it is composed of a first element (head) and a tail, which is a list itself. In Prolog we represent the empty list by the atom [] and a non-empty list by a term [H|T] where H denotes the head and T denotes the tail.
(NOTE:- Given list MySenarai= [a,b,c,d,e,f, g, h] for the tasks listed below)

i. Find the last element of a list.
?-
Output:-

ii. Find the K'th element of a list. (K=5)
?-
Output:-

iii. Eliminate consecutive duplicates of list elements.
?-
Output:-

iv. Find the number of elements of a list.
?-
Output:-





v. Reverse a list.
?-
Output:-

vi. Find out whether a list is a palindrome.
?-
Output:-
vii. Duplicate the elements of a list.
?-
Output:-

viii. Drop every N'th element from a list. (N=3)
?-
Output:-

ix. Insert an element at a given position into a list. (element = zzz)
?-
Output:-

x. Extract a slice from a list. (I = 2; k = 5)
Given two indices, I and K, the slice is the list containing the elements between the I'th and K'th element of the original list (both limits included). Start counting the elements with 1
?-
Output:-
Assignment - Cooking
The task is to create a simple decision support system for cooking.
Predicate in the database has the following syntax:

at_home ([ingredient (rice, 2), ingredient (water, 10)]).

The predicate at_home, so is
rice ingredient and 2 represent the amount of rice available at home.

Recipe (boiled_rice, [ingredient (rice, 4), ingredient (salt, 3), ingredient (water, 5)]).
recipe (chicken, [ingredient (chicken, 2), ingredient (salt, 1), ingredient (pepper, 1)]).

The predicate recipe, so is rice (or chicken) dish and the second argument is a list of ingredients needed to cook the dish.
Information

After defining the database (and added some recipes), you will write two predicates:
First Cook (X) provides an answer to what can be repaired by the ingredients available at home.
The question can also be "Can I cook dish X". Responses should be the various options available to cook.
Second buy (X, L), the quantities of different ingredients that must be purchased in order to cook the dish x.
The program shall gather Required ingredients and quantities in the list L. The question must also be able to buy (X, L). which shall enumerate (with ';') all known recipes and what needs to be purchased in order to cook them.
A possible solution to buy (Rice, L), from the above example, can be: L = [ingredient (rice, 2), ingredient (salt, 3)]
It is appropriate to break down and preached in the sub-tasks as using predicates can take care of. Examples of such may be (but there are more ways to divide the problem): at_home (Type, Amount): talking about how much it is home of the ingredient type. need_to_buy (Needed, BuyList): creates a shopping list (BuyList) given a list of the essential ingredients (Needed). Since both the cook and buy to enumerate solutions should be the declarative predicate
How can I write Program that reads marks of a students and displays grade with prolog programing?
where i can download prolog swi ?
LATEST TUTORIALS
APPROVED BY CLIENTS