package org.matheclipse.core.builtin.function;
import org.matheclipse.core.eval.exception.Validate;
import org.matheclipse.core.eval.interfaces.AbstractCoreFunctionEvaluator;
import org.matheclipse.core.expression.F;
import org.matheclipse.core.interfaces.IAST;
import org.matheclipse.core.interfaces.IExpr;
import org.matheclipse.core.interfaces.ISymbol;
import com.google.common.base.Predicate;
/**
* Returns True, if the given expression is an atomic object (i.e. no AST instance)
*
*/
public class AtomQ extends AbstractCoreFunctionEvaluator implements Predicate {
/**
* Constructor for the unary predicate
*/
public final static AtomQ CONST = new AtomQ();
public AtomQ() {
}
/**
* Returns True if the 1st argument is an atomic object; False otherwise
*/
@Override
public IExpr evaluate(final IAST ast) {
Validate.checkSize(ast, 2);
IExpr arg1 = F.eval(ast.arg1());
return F.bool(arg1.isAtom());
}
@Override
public void setUp(final ISymbol symbol) {
symbol.setAttributes(ISymbol.LISTABLE);
}
public boolean apply(final IExpr obj) {
return obj.isAtom();
}
}
Ads help maintain this website.