From: ······@gmail.com
Subject: Not printing the variable instantiations
Date: 
Message-ID: <1181150200.170857.120220@i38g2000prf.googlegroups.com>
I wrote a prolog program to count the number of 1's in a list.
I am using SWI prolog.


%--------------------------------
count([],0).
count([1|T], N) :-
	count(T,M);
	N is M+1.

count([H|T], N) :-
	count(T, N).

one(1).
%--------------------------------

When I try the query

?- count([1,2,3],N).

I am getting the answer as YES.

It is not giving any other thing. I want instantiations for N.

All the other are getting printer correctly except this.

From: Rainer Joswig
Subject: Re: Not printing the variable instantiations
Date: 
Message-ID: <joswig-55DC03.19571906062007@news-europe.giganews.com>
In article <························@i38g2000prf.googlegroups.com>,
 ······@gmail.com wrote:

> I wrote a prolog program to count the number of 1's in a list.
> I am using SWI prolog.
> 
> 
> %--------------------------------
> count([],0).
> count([1|T], N) :-
> 	count(T,M);
> 	N is M+1.
> 
> count([H|T], N) :-
> 	count(T, N).
> 
> one(1).
> %--------------------------------
> 
> When I try the query
> 
> ?- count([1,2,3],N).
> 
> I am getting the answer as YES.
> 
> It is not giving any other thing. I want instantiations for N.
> 
> All the other are getting printer correctly except this.

Checkout comp.lang.prolog ! ;-)

-- 
http://lispm.dyndns.org
From: Stefan Mandl
Subject: Re: Not printing the variable instantiations
Date: 
Message-ID: <5colcmF316m4jU1@mid.dfncis.de>
> Checkout comp.lang.prolog ! ;-)

Indeed!

Besides, your mistake is to use ";" instead of "," in the second clause.