Home > Archive > Prolog > December 2006 > Getting status of a free variable.
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 |
Getting status of a free variable.
|
|
| andrea 2006-12-13, 4:16 pm |
| Hello everyone,
Maybe it's very easy but I don't find anywhere a solution.
I need to know if a free variable is unified with any kind of value,
for example:
sillabo(Word,[H|T]) :- ....
sillabo(Word,[Last,Current | T]) :- ...
I want it to go to the second goal only if the actual list has already
a Last element that's unified with a value.
I'm sorry for my english and my prolog dictionary...
I'll try to be clearer if you don't understand my problem.
| |
| Mauro Di Nuzzo 2006-12-13, 4:16 pm |
| I dont know if I understood exactly, but it seems to me that you have just
to invert clauses, that is:
sillabo(Word,[Last,Current | T]) :-
nonvar(Last), !, ...
sillabo(Word,[H|T]) :- ....
Cheers
/\/\
"andrea" <kerny404@gmail.com> ha scritto nel messaggio
news:1165924229.460939.58060@j72g2000cwa.googlegroups.com...
> Hello everyone,
> Maybe it's very easy but I don't find anywhere a solution.
>
> I need to know if a free variable is unified with any kind of value,
> for example:
>
> sillabo(Word,[H|T]) :- ....
>
> sillabo(Word,[Last,Current | T]) :- ...
>
>
> I want it to go to the second goal only if the actual list has already
> a Last element that's unified with a value.
> I'm sorry for my english and my prolog dictionary...
> I'll try to be clearer if you don't understand my problem.
>
| |
| Mauro Di Nuzzo 2006-12-13, 4:16 pm |
| I didnt read it carefully. So it seems that the only thing you need is the
predicate nonvar/1, that is
sillabo(Word,[H| T]) :-
nonvar(H), !, ...
sillabo(Word,[H|T]) :- ....
"Mauro Di Nuzzo" <picorna@inwind.it> ha scritto nel messaggio
news:457ea77e$0$4251$4fafbaef@reader1.news.tin.it...
>I dont know if I understood exactly, but it seems to me that you have just
>to invert clauses, that is:
>
> sillabo(Word,[Last,Current | T]) :-
> nonvar(Last), !, ...
>
> sillabo(Word,[H|T]) :- ....
>
> Cheers
> /\/\
>
>
> "andrea" <kerny404@gmail.com> ha scritto nel messaggio
> news:1165924229.460939.58060@j72g2000cwa.googlegroups.com...
>
>
| |
| andrea 2006-12-13, 4:16 pm |
| Yes thank you very much, nonvar/1 was the answer :)
On 12 Dic, 14:01, "Mauro Di Nuzzo" <pico...@inwind.it> wrote:[color=darkred]
> I didnt read it carefully. So it seems that the only thing you need is the
> predicate nonvar/1, that is
>
> sillabo(Word,[H| T]) :-
> nonvar(H), !, ...
>
> sillabo(Word,[H|T]) :- ....
>
> "Mauro Di Nuzzo" <pico...@inwind.it> ha scritto nel messaggionews:457ea77e$0$4251$4fafbaef@r
eader1.news.tin.it...
>
>
>
>
>
>
>
>
>
|
|
|
|
|