Re: Can I do something like this
Roberto Bagnara <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Organization | Department of Mathematics and Computer Science, University of Parma, Italy |
| Message-ID | <[email protected]> |
On 03/23/14 21:05, Roelof Wobben wrote:
> I have a predicate which has 2 possibilities.
>
> the parameter is substained or not.
>
> Can I do something like this now.
>
> my_predicate(var(x)) :-
> write("The solutions are").
>
> my_predicate(nonvar(x) )
> write("the pairs are").
>
> Or can I better do :
>
> my_predicate(x) :-
> var(x),
> write ( ).
>
> my_predicate(x) :-
> nonvar(x),
> write ( ).
Short answer: no.
Longer answer: Learning any programming language requires some effort.
From what you write, I gather you did not even care to read the first
few pages of any Prolog book. If you want to learn Prolog, start
by reading Chapter 1 of, e.g.,
http://www.learnprolognow.org/lpnpage.php?pageid=online
This already will tell you why what you wrote makes little sense in
Prolog. Then continue with Chapter 2, 3, ... I am sorry if this
sounds like too much work, but really there is no other way.
Hope it helps,
Roberto
--
Prof. Roberto Bagnara
Applied Formal Methods Laboratory - University of Parma, Italy
mailto:[email protected]
BUGSENG srl - http://bugseng.com
mailto:[email protected]