Home > Archive > Prolog > March 2005 > Help me with prolog
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Help me with prolog
|
|
|
| Hi,
I am a student from university of Palermo (Italy) and I have some problem
with the prolog.
If I have a list of literal [a,b,c,d], how do I create a new list where I
add +4 (or - 4) ( or anotrher number) at the list of departure and I create
the list [e,f,g,h] ?
How I create a list of literal circular?
How I replace a list of literal with a number (ex: se I have the list
[a,b,c,d] and I want replace only some the atom ( a with 2, c with 5 and
leave b and d to their place)) ??
Thank you for the help.
Charles
| |
| Bart Demoen 2005-03-06, 8:56 am |
| Char wrote:
> Hi,
> I am a student from university of Palermo (Italy) and I have some problem
> with the prolog.
>
> If I have a list of literal [a,b,c,d], how do I create a new list where I
> add +4 (or - 4) ( or anotrher number) at the list of departure and I create
> the list [e,f,g,h] ?
> How I create a list of literal circular?
> How I replace a list of literal with a number (ex: se I have the list
> [a,b,c,d] and I want replace only some the atom ( a with 2, c with 5 and
> leave b and d to their place)) ??
Why don't you send us the original home work statement in Italian, so
that there is no ambiguity about what you are really asking for ?
A pointer to the web page with the home work will also do.
Cheers
Bart Demoen
| |
|
|
problem[color=darkred]
I[color=darkred]
create[color=darkred]
>
> Why don't you send us the original home work statement in Italian, so
> that there is no ambiguity about what you are really asking for ?
> A pointer to the web page with the home work will also do.
>
> Cheers
>
> Bart Demoen
The questions were assignmentsof exam to which have not known to answer.
Cmq, I write in italian:
Se ho una lista di letterali [a,b,c,d], come creo una nuova lista dove,
aggiungendo ad ogni letterali un numero ( ex: a+4, b+4, ecc), creo la lista
[e,f,g,h] ??
Come creo una lista circulare (cioč, appena arrivo a Z ricomncia di nuovo da
A)?
Se devo creare un lista criptata, come faccio in una lista [a,b,c,d] a
sostituire solo alcuni termini con dei termini assegnati (cioč, ad A assegno
4, a c assegno 7, cosi da creare la lista cripata [4,b,7,d] ))??
Spero in una vostro aiuto visto con il prolog non me la cavo proprio.
Ciao
Charles
| |
| Pierpaolo BERNARDI 2005-03-07, 4:04 pm |
| On Sun, 6 Mar 2005 10:30:15 +0100, Char <coalchamber@NOPUBBLICITAinwind.it> wrote:
> Se ho una lista di letterali [a,b,c,d], come creo una nuova lista dove,
> aggiungendo ad ogni letterali un numero ( ex: a+4, b+4, ecc), creo la lista
> [e,f,g,h] ??
> Come creo una lista circulare (cioĆØ, appena arrivo a Z ricomncia di nuovo da
> A)?
>
> Se devo creare un lista criptata, come faccio in una lista [a,b,c,d] a
> sostituire solo alcuni termini con dei termini assegnati (cioĆØ, ad A assegno
> 4, a c assegno 7, cosi da creare la lista cripata [4,b,7,d] ))??
esercizio1([],[]).
esercizio1([X|Xs],[X1|Xs1]) :-
atom_codes(X,[C|_]),
C1 is C+4,
atom_codes(X1,[C1]),
esercizio1(Xs,Xs1).
sfondata([],U,U).
sfondata([X|Xs],[X|Xs1],U) :-
sfondata(Xs,Xs1,U).
esercizio2(X,C) :-
sfondata(X,C,C).
esercizio3(Lista,Sostituzioni,Crittata) :-
findall(Crittato,
(member(C,Lista),crittatomo(C,Sostituzio
ni,Crittato)),
Crittata).
crittatomo(A,Sostituzioni,Crittato) :-
member(A-Crittato,Sostituzioni),
!.
crittatomo(A,_,A).
/*
23 ?- esercizio3([a,b,c,d],[a-4,c-7],C).
C = [4, b, 7, d] ;
*/
> Spero in una vostro aiuto visto con il prolog non me la cavo proprio.
Male. 8^)
Ciao
P.
|
|
|
|
|