Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package jason.stdlib;
 

Internal action: .literal.

Description: checks whether the argument is a literal, e.g.: "p", "p(1)", "p(1)[a,b]", "~p(1)[a,b]".

Parameter:

  • + argument (any term): the term to be checked.

Examples:

  • .literal(b(10)): true.
  • .literal(b): true.
  • .literal(10): false.
  • .literal("Jason"): false.
  • .literal(X): false if X is free, true if X is bound to a literal.
  • .literal(a(X)): true.
  • .literal([a,b,c]): false.
  • .literal([a,b,c(X)]): false.

public class literal extends DefaultInternalAction {
    
    private static InternalAction singleton = null;
    public static InternalAction create() {
        if ( == null
             = new literal();
        return ;
    }
    @Override public int getMinArgs() { return 1; }
    @Override public int getMaxArgs() { return 1; }
    @Override
    public Object execute(TransitionSystem tsUnifier unTerm[] argsthrows Exception {
        checkArguments(args);
        return args[0].isLiteral();
    }
New to GrepCode? Check out our FAQ X