Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi G - M > Logica matematica > Esercizio ProLog - compitino 17 giugno
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Paolo74GRS
.primate.

User info:
Registered: Mar 2003
Posts: 71 (0.01 al dì)
Location: Bergamo
Corso: Informatica
Anno: > 3
Time Online: 2 Days, 11:55:02: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Question Esercizio ProLog - compitino 17 giugno

Ciao a tutti.. posto questo messaggio per chiedere a qualcuno di voi la risoluzione del primo esercizio del compitino di ProLog dello scorso 17 giugno... ho provato diverse volte a farlo e rifarlo ma.... gli ultimi passaggi, dove le conc dovrebbero compormi la lista L2 inversa rispetto ad L1 mi fanno perdere in un labirinto!!!

HELP!!! :?

:pensa:

:help:

..questo è il programma ed il relativo quesito:

conc([], L, L).
conc([X|L1], L2, [X|L3]):- conc(L1, L2, L3).
invers([], []).
invers([T|C], L2):- invers(C, L1), conc(L1, [T], L2).

L1=[e, f, g], invers(L1, L2).

...il risultato, testato anche con SWI-ProLog, è:

L1 = [e, f, g],
L2 = [g, f, e]

:?

28-06-2010 09:42
Click Here to See the Profile for Paolo74GRS Click here to Send Paolo74GRS a Private Message Find more posts by Paolo74GRS Add Paolo74GRS to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Lightbreeze
...

User info:
Registered: Jan 2009
Posts: 24 (0.00 al dì)
Location: novara-milano
Corso: Informatica
Anno:
Time Online: 23:27:57 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Dovrebbe essere così
la prima parte è semplice:
cambio variabili -> H=[e, f, g], invers(H, K).
regola 1 -> invers([e,f,g], K).
regola 4 -> invers( [f,g], A), conc(A, [e],K).
regola 4 -> invers([g], B), conc(B, [f], A), conc(A, [e],K).
regola 4 -> invers([], D), conc(D, [g], B), conc(B, [f], A), conc(A, [e],K).
regola 3 (D=[]) -> conc([], [g], B), conc(B, [f], A), conc(A, [e],K).
regola 1 (B=[g]) -> conc([g], [f], A), conc(A, [e],K).
ora,
regola 2 X=g, L1=[], L2=[f], A=[g|L3] -> conc([],[f],L3), conc([g|L3], [e], K).
regola 1 L3=[f] -> conc([g,f], [e], K).
regola 2 X'=g, L1'=[f], L2'=[e], K=[g|L3'] -> conc([f], [e], L3').
regola 2 X"=f, L1"=[], L2"=[e], L3'=[f|L3"] -> conc([], [e], [L3"]).
regola 1 L3"=[e] -> clausola vuota
Finito! H=[e,f,g] K=[g|L3'] = [g| [f|L3"] ] =[g|[f|[e]]]= [g,f,e]
Spero sia comprensibile :D

28-06-2010 12:28
Click Here to See the Profile for Lightbreeze Click here to Send Lightbreeze a Private Message Find more posts by Lightbreeze Add Lightbreeze to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 13:50.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.028 seconds (75.59% PHP - 24.41% MySQL) con 28 query.