Find Jobs
Hire Freelancers

96374 Prolog

N/A

Completato
Pubblicato più di 17 anni fa

N/A

Pagato al completamento
This is the assignment that I have been given. I use a version called LPA Prolog for writing the code: The following Prolog database records details of the friendships that exist between various individuals, as well as information about their respective interests. friends( john, [fred,sue,george] ). % fred, sue & george are friends of john friends( fred, [sue] ). friends( sue, [fred,george] ). friends( george, [ ] ). % george has no friends male( john ). % john is male male( fred ). male( george ). female( sue ). interests( john, [sport] ). % john is interested in sport interests( fred, [music] ). interests( george, [sport,music] ). % george is interested in sport and music interests( sue, [music] ). Note that friendship is not a symmetrical relationship. for example, within this database, Fred is a friend of John – but John is not a friend of Fred. Write and test the following Prolog programs. a) all_friends/3 takes the names of two individuals (arguments 1 & 2) and finds the list (argument 3) of all their friends – e.g. ?- all_friends( john, sue, FRIENDS ). FRIENDS = [fred,sue,george,fred,george] (10%) b) common_friend/3 finds the names of two individuals (arguments 1 & 2) who have at least one friend (argument 3) in common – e.g. ?- common_friend( P1, P2, F ). P1 = john P2 = fred F = sue (10%) c) chums/2 finds the names of two individuals who are friends of one another (i.e. argument 1 is a friend of argument 2 and vice-versa) – e.g. ?- chums( john, fred ). no ?- chums( C1, C2 ). C1 = fred C2 = sue (10%) d) buddies/2 finds the names of two individuals who are friends of one another (i.e. argument 1 is a friend of argument 2 and vice-versa) and who also share a common interest – e.g. ?- buddies( sue, BUDDY ). BUDDY = fred (10%) e) add_friend/2 updates the database by adding argument 2 as a friend of argument 1, and prints out the new list of friends as confirmation – e.g. ?- add_friend( fred, john ). freds friends are [john,sue] (10%) f) update/1 displays a menu that offers the user three options: i) add to someone’s list of friends. ii) add to someone’s list of interests. iii) quit. The menu should be redisplayed until the user selects the quit option – e.g. ?- update(george). Please choose an option. 1. add a friend 2. add an interest 3. quit |: 1. who is new friend? |: fred. georges friends are [fred] Please choose an option. 1. add a friend 2. add an interest 3. quit etc. (20%)
Rif. progetto: 1842540

Info sul progetto

1 proposta
Progetto a distanza
Attivo 12 anni fa

Hai voglia di guadagnare un po'?

I vantaggi delle offerte su Freelancer

Imposta il tuo budget e le scadenze
Fatti pagare per il lavoro svolto
Delinea la tua proposta
La registrazione e le offerte sui lavori sono gratuite
Assegnato a:
Avatar dell'utente
As discussed.
$35 USD in 0 giorno
0,0 (0 valutazioni)
0,0
0,0

Info sul cliente

Bandiera:
0,0
0
Membro dal nov 10, 2006

Verifica del cliente

Altri lavori del cliente

100078 Prolog
N/A
Grazie! Ti abbiamo inviato tramite email il link per richiedere il tuo bonus gratuito.
Non è stato possibile inviarti l'email. Riprova per piacere.
di utenti registrati di lavori pubblicati
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Caricamento anteprima
Autorizzazione per la geolocalizzazione concessa.
La tua sessione è scaduta ed è stato effettuato il log out. Accedi nuovamente per piacere.