Counting the solutions....

gowtham <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
Hi All,
Bear with this newbie. I come from procedural programming and started to
learn prolog a week ago. Though, I really appreciate its amazing capacity, i
am still struggling to learn the basics.

My quaries are getting the solutions but, i have problem in counting the
solutions.

My knowledgebase has fact like following....

node('LmjF01.0010').
node('LmjF01.0020').
node('LmjF01.0030').
 prop('LmjF01.0010', is_coding, 'YES').
 prop('LmjF01.0010', is_coding, 'YES').
 prop('LmjF01.0010', is_coding, 'NO').
prop('LmjF01.0010', located_on, 'Lmjchr1').
prop('LmjF01.0010', located_on, 'Lmjchr1').
prop('LmjF01.0010', located_on, 'Lmjchr2').

function:
%count protein coding genes from GFF
count_pcg0(X) :-
Goal= prop(X, is_coding, 'YES'),
counter(Goal, N),
fail.

It counts and gives me the actual count in numbers.

But, when I add more conditions to it, It returns 1 or 0 depending on if it
fails or passes.
For example,
count_pcg(X) :-
node(X),
prop(X, is_coding, 'YES'),
G2 = prop(X, located_on, 'Lmjchr1'),
counter(G2, N),
fail.


%---------------------------------------
% Basic Functions
%---------------------------------------
counter(Goal, N) :-
   flag(counter, Outer, 0),
  (
     call(Goal),
     flag(counter, Inner, Inner+1),
     fail;
     flag(counter, Count, Outer),
     N = Count,
     write(N)
).






> _______________________________________________
> Users-prolog mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/users-prolog
>
>
Thanks a lot ,
I'll really appreciate your help

-- 
Gowthaman

Bioinformatics Systems Programmer.
SBRI, 307 West lake Ave N Suite 500
Seattle, WA. 98109-5219
Phone : LAB 206-256-7188 (direct).

_______________________________________________
Users-prolog mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/users-prolog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.