Search in sources :

Example 1 with RulesData

use of org.matheclipse.core.patternmatching.RulesData in project symja_android_library by axkr.

the class BuiltInDummy method readRules.

/**
 * {@inheritDoc}
 */
@Override
public void readRules(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
    fSymbolName = stream.readUTF();
    fAttributes = stream.read();
    boolean hasDownRulesData = stream.readBoolean();
    if (hasDownRulesData) {
        fRulesData = new RulesData();
        fRulesData = (RulesData) stream.readObject();
    }
}
Also used : RulesData(org.matheclipse.core.patternmatching.RulesData)

Example 2 with RulesData

use of org.matheclipse.core.patternmatching.RulesData in project symja_android_library by axkr.

the class SerializableTest method testIntegrateDefinition.

public void testIntegrateDefinition() {
    RulesData rulesData = F.Integrate.getRulesData();
    AbstractVisitor visitor = Share.createVisitor();
    rulesData.accept(visitor);
    equalsStringCopy(rulesData);
}
Also used : AbstractVisitor(org.matheclipse.core.visit.AbstractVisitor) RulesData(org.matheclipse.core.patternmatching.RulesData)

Example 3 with RulesData

use of org.matheclipse.core.patternmatching.RulesData in project symja_android_library by axkr.

the class SerializableTest method testSinDefinition.

public void testSinDefinition() {
    // try to share common sub-IASTs first:
    RulesData rulesData = F.Sin.getRulesData();
    AbstractVisitor visitor = Share.createVisitor();
    rulesData.accept(visitor);
    equalsCopy(rulesData);
}
Also used : AbstractVisitor(org.matheclipse.core.visit.AbstractVisitor) RulesData(org.matheclipse.core.patternmatching.RulesData)

Example 4 with RulesData

use of org.matheclipse.core.patternmatching.RulesData in project symja_android_library by axkr.

the class PatternMatching method messageName.

public static IExpr messageName(ISymbol symbol, IExpr expr) {
    RulesData rules = symbol.getRulesData();
    if (rules != null) {
        Map<IExpr, PatternMatcherEquals> map = rules.getEqualDownRules();
        PatternMatcherEquals matcher = map.get(F.MessageName(symbol, expr));
        if (matcher != null) {
            return matcher.getRHS();
        }
    }
    return F.NIL;
}
Also used : RulesData(org.matheclipse.core.patternmatching.RulesData) PatternMatcherEquals(org.matheclipse.core.patternmatching.PatternMatcherEquals) IExpr(org.matheclipse.core.interfaces.IExpr)

Example 5 with RulesData

use of org.matheclipse.core.patternmatching.RulesData in project symja_android_library by axkr.

the class PatternMatching method optionsList.

/**
 * Returns a list of the default options of a symbol defined by <code>Option(f)={a->b,...}</code>.
 *
 * @param symbol
 * @param optionValueRules convert to &quot;string&quot;" rules, suitable for <code>OptionValue
 *     </code>
 * @return
 */
public static IAST optionsList(ISymbol symbol, boolean optionValueRules) {
    RulesData rules = symbol.getRulesData();
    if (rules != null) {
        Map<IExpr, PatternMatcherEquals> map = rules.getEqualDownRules();
        PatternMatcherEquals matcher = map.get(F.Options(symbol));
        if (matcher != null) {
            IExpr temp = matcher.getRHS();
            if (optionValueRules) {
                IASTAppendable result = F.ListAlloc(10);
                extractRules(temp, result);
                return result;
            }
            if (temp.isList()) {
                return (IAST) temp;
            }
            return F.list(temp);
        }
    }
    return F.CEmptyList;
}
Also used : IASTAppendable(org.matheclipse.core.interfaces.IASTAppendable) RulesData(org.matheclipse.core.patternmatching.RulesData) PatternMatcherEquals(org.matheclipse.core.patternmatching.PatternMatcherEquals) IExpr(org.matheclipse.core.interfaces.IExpr) IAST(org.matheclipse.core.interfaces.IAST)

Aggregations

RulesData (org.matheclipse.core.patternmatching.RulesData)10 AbstractVisitor (org.matheclipse.core.visit.AbstractVisitor)5 IExpr (org.matheclipse.core.interfaces.IExpr)3 IAST (org.matheclipse.core.interfaces.IAST)2 PatternMatcherEquals (org.matheclipse.core.patternmatching.PatternMatcherEquals)2 Kryo (com.esotericsoftware.kryo.Kryo)1 Input (com.esotericsoftware.kryo.io.Input)1 Output (com.esotericsoftware.kryo.io.Output)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IASTAppendable (org.matheclipse.core.interfaces.IASTAppendable)1 IBuiltInSymbol (org.matheclipse.core.interfaces.IBuiltInSymbol)1 ISymbol (org.matheclipse.core.interfaces.ISymbol)1