More on Increment in Prolog

From: gwizbmc (gwizbmc_at_hotmail.com)
Date: 02/24/04

  • Next message: gwizbmc: "How to use cntr_inc(Counter,Value)?More on Counter in Prolog!"
    Date: Tue, 24 Feb 2004 08:32:25 -0600
    
    

    What if we're dealing with a small database of ,let's say, students information, and we're not looking for the simple :"look-for, unify, and write" thingy that is simple to do in Prolog, but instead we want to know the "Number" of students that we have in our database who satisfy certain conditions(i.e: older than 22, or completed more than 40 Credits, etc...)
    How can we incorporate a counter in the function that searchs through each term by back-tracking, and get back the value stored in that counter , after all terms are searched, to be written on the output stream (i.e: the screen)?

    Amzi Prolog has a : cntr_inc(Counter,Value) that should help out.
    any example to clarify its usage and the nature of "Value" and "Counter" would be greatly appreciated.
    thanks.


  • Next message: gwizbmc: "How to use cntr_inc(Counter,Value)?More on Counter in Prolog!"