Need help urgently!!!!
From: DonalMagennis (donal_magennis_at_hotmail-dot-com.no-spam.invalid)
Date: 03/01/05
- Next message: Brian Hulley: "Re: Need help urgently!!!!"
- Previous message: Pere Montolio: "Re: Newbie question about list"
- Next in thread: Brian Hulley: "Re: Need help urgently!!!!"
- Reply: Brian Hulley: "Re: Need help urgently!!!!"
- Reply: student: "Re: Need help urgently!!!!"
- Reply: DonalMagennis: "re:Need help urgently!!!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Mar 2005 06:05:27 -0600
I can't get to grips with prolog at all and need help with these
problems. I know bits and pieces but just can't glue it all together
so to speak! Any help gratefull, cheers.
Write Prolog facts describing five fictitious employees and the
languages they speak e.g.
languages(mary, [french, english]).
languages(john, [english, german, french]).
Write separate Prolog queries to find employees who:
- speak both English and French
- speak at least three languages
Write a Prolog predicate called all_languages to create a list of all
the languages spoken by two given employees. The list created should
be sorted in alphabetical order and contain no duplicates e.g.
?- all_languages(mary, john, L).
L = [english, french, german]
Write Prolog facts in which five fictitious cars are described as
lists of attribute-value pairs e.g.
details(car1, [owner, john, colour, blue, make, ford, type,
hatchback, doors, 3]).
details(car2, [colour, red, make, volkswagen, type, saloon,
owner, sue]).
Write a Prolog predicate called describe to output a
description of a given car with each attribute and its value on a
separate line e.g.
?- describe(car2).
colour = red
make = volkswagen
type = saloon
owner = sue
(Hint: describe should call another predicate that resembles
the writelist predicate from the lecture notes, and uses the [First,
Second | Rest] notation to access the elements of a list in pairs.)
Your solution should include a commented listing of your Prolog
database and a single transcript of your describe predicate in use.
Write Prolog facts describing five fictitious A-level students and the
subjects they are studying e.g.
subjects(mary, [maths, french, english]).
subjects(john, [french, english, german, history]).
Write a Prolog predicate called studies to find students who
study a given subject e.g.
?- studies(Who, english).
Who = mary ;
Who = john
Use your studies predicate in another predicate called
all_students to create a list of all students who study a given
subject. The student names in the list should be in alphabetical
order e.g.
?- all_students(french, L).
L = [andrew, john, mary]
Your solution should include a commented listing of your
Prolog database and a single transcript of each predicate in use.
A simple grammar for a small subset of English is shown below.
sentence --> noun phrase, verb phrase
noun phrase --> determiner, adjective, noun
noun phrase --> determiner, noun
verb phrase --> verb, noun_phrase
verb phrase --> verb.
determiner --> the
noun --> woman
noun --> fly
noun --> spider
noun --> mouse
noun --> cat
noun --> dog
noun --> horse
verb --> swallows
adjective --> old
Implement the grammar in Prolog and write queries to find legal
sentences (not just completions of sentences) that:
(a) contain less than 4 words
(b) do not contain the word “woman”
(c) start with the words “the old woman”
(d) end with the words “swallows the fly”
(e) contain the word “fly” more than once
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
- Next message: Brian Hulley: "Re: Need help urgently!!!!"
- Previous message: Pere Montolio: "Re: Newbie question about list"
- Next in thread: Brian Hulley: "Re: Need help urgently!!!!"
- Reply: Brian Hulley: "Re: Need help urgently!!!!"
- Reply: student: "Re: Need help urgently!!!!"
- Reply: DonalMagennis: "re:Need help urgently!!!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|