Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package jason.functions;

Function: .count(B): counts the number of occurrences of a particular belief (pattern) in the agent's belief base, as the internal action .count.


  • .count(a(2,_)): returns the number of beliefs that unify with a(2,_).

See also:
jason.stdlib.count internal action version
public class Count extends DefaultArithFunction  {
	public String getName() {
	    return ".count";
	public double evaluate(TransitionSystem tsTerm[] argsthrows Exception {
	    if (ts == null) {
            throw new JasonException("The TransitionSystem parameter of the function '.count' cannot be null.");
        LogicalFormula logExpr = (LogicalFormula)args[0];
        int n = 0;
        Iterator<Unifieriu = logExpr.logicalConsequence(ts.getAg(), new Unifier());
        while (iu.hasNext()) {
        return n;
	public boolean checkArity(int a) {
		return a == 1;
	public boolean allowUngroundTerms() {
	    return true;
New to GrepCode? Check out our FAQ X