Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...At last there is indeed a website/forum that deals with professional and serious matters. Keep up with the good work!!"

Geography

Where in the world do Tek-Tips members come from?

Count the number of results.Helpful Member! 

Tenes (IS/IT--Management)
29 Sep 10 16:57
Hello,

Suppose we have this example (my real problem has 45 regions here is only 7):

%Coloring Australia
coloring(Wa,Nt,Sa,Ql,Nsw,V,T):-


%Country borders relation to other Countries
different(Wa,Nt),
different(Wa,Sa),
different(Nt,Wa),
different(Nt,Sa),
different(Nt,Ql),
different(Sa,Wa),
different(Sa,Nt),
different(Sa,Ql),
different(Sa,Nsw),
different(Sa,V),
different(Ql,Nt),
different(Ql,Sa),
different(Ql,Nsw),
different(Nsw,Ql),
different(Nsw,Sa),
different(Nsw,V),
different(V,T).
%different(T,V).


%Color relation to other Colors
different(yellow,blue).
different(blue,yellow).
different(yellow,red).
different(red,yellow).
different(blue,red).
different(red,blue).

I want to count how many different results the query
coloring(Wa,Nt,Sa,Ql,Nsw,V,T). will give.

Thanks in advance
Helpful Member!  joel76 (Programmer)
30 Sep 10 3:21
You can use setof/3 to get the list of all the different solutions, then use length/2 to get the number of these solutions.
Tenes (IS/IT--Management)
30 Sep 10 4:38
Can you give me an example?

I only need a counter with the results (in this example is 12).

 
joel76 (Programmer)
30 Sep 10 5:53
try

CODE

setof([Wa,Nt,Sa,Ql,Nsw,V,T], coloring(Wa,Nt,Sa,Ql,Nsw,V,T), L), length(L, N).
Tenes (IS/IT--Management)
30 Sep 10 6:24
you are the best joel thx

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close