|
|
CUT(!) and FINDALL/3 URGENT: msg#01591
|
Subject: |
CUT(!) and FINDALL/3 URGENT |
Hi,
I have an urgent doubt. For example when I ask to prolog
?- member( 3, [1,2,3]).
Yes
Is there any system variable associated with the prolog answer "Yes" or "No" ???
I have this doubt because I want to use the answer in programs (e.g. if answer=Yes then ....)
I know that is possible with :
The goal member(3,[1,2,3]) succeeds and you can use that in a
conjunction or in an if-then-else, as in
member(3,[1,2,3]), writeln('3 is a member of [1,2,3])
or
(member(3,[1,2,3]) ->
writeln(success)
;
writeln(failure)
)
but I need to Know how I can do with CUT.
I have to know do a problem, where objective is to implement a function where is order two lists for user. The program it will have write in screen list of the elements that belong the two simultaneously. I need do this with function findall/3.
Example:
The important is point 6.
OPERAÇÕES SOBRE CONJUNTOS
MENU
1- Verificar se a intersecção entre 2 linhas é a lista vazia
2- Verificar se 2 conjuntos são disjuntos
3- Verificar se uma lista está ordenada
4- Calcular a intersecção de 2 listas
5- Calcular a reunião de 2 listas
6- To calculate the elements that simultaneously do not belong the 2 given lists
0- Para sair do programa
Escolher o numero que corresponde à opcção desejada:
|: 6.
Introduza a 1ª lista. Deve ser escrita na forma [elem1...elemn]- [1,2,3,4].
Introduza a 2ª lista. Deve ser escrita na forma [elem1...elemn]- [1,3,4,9].
The result it will have: [2,9]
Sent from the SWI Prolog forum at Nabble.com:
CUT(!) and FINDALL/3 URGENT
|
| |