⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mathcommands.java

📁 计算机代数系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      iter.GoNext();      ind--;    }    LispPtr toInsert = new LispPtr();    toInsert.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 3).Get());    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,iter.Ptr() != null, 2);    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,iter.Ptr().Get() != null, 2);    toInsert.Get().Next().Set(iter.Ptr().Get().Next().Get());    iter.Ptr().Set(toInsert.Get());    YacasEvalCaller.RESULT(aEnvironment, aStackTop).Set(LispSubList.New(copied.Get()));  }  /// Implements the Yacas functions \c RuleBase and \c MacroRuleBase .  /// The real work is done by LispEnvironment::DeclareRuleBase().  public static void InternalRuleBase(LispEnvironment aEnvironment, int aStackTop,  boolean aListed) throws Exception  {    //TESTARGS(3);        // Get operator    LispPtr args = new LispPtr();    String orig=null;        LispError.CHK_ARG_CORE(aEnvironment,aStackTop,YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get() != null, 1);    orig = YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get().String();    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1);    args.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 2).Get());        // The arguments    LispError.CHK_ISLIST_CORE(aEnvironment,aStackTop,args,2);    // Finally define the rule base    aEnvironment.DeclareRuleBase(LispStandard.SymbolName(aEnvironment,orig),                                 args.Get().SubList().Get().Next(),aListed);        // Return true    LispStandard.InternalTrue(aEnvironment,YacasEvalCaller.RESULT(aEnvironment, aStackTop));  }  public static void InternalNewRule(LispEnvironment aEnvironment, int aStackTop) throws Exception  {    //TESTARGS(6);    int arity;    int precedence;    LispPtr ar = new LispPtr();    LispPtr pr = new LispPtr();    LispPtr predicate = new LispPtr();    LispPtr body = new LispPtr();    String orig=null;        // Get operator    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get() != null, 1);    orig = YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get().String();    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1);    ar.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 2).Get());    pr.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 3).Get());    predicate.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 4).Get());    body.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 5).Get());        // The arity    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,ar.Get() != null, 2);    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,ar.Get().String() != null, 2);    arity = Integer.parseInt(ar.Get().String(),10);    // The precedence    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,pr.Get() != null, 3);    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,pr.Get().String() != null, 3);    precedence = Integer.parseInt(pr.Get().String(),10);        // Finally define the rule base    aEnvironment.DefineRule(LispStandard.SymbolName(aEnvironment,orig),                            arity,                            precedence,                            predicate,                            body );    // Return true    LispStandard.InternalTrue(aEnvironment,YacasEvalCaller.RESULT(aEnvironment, aStackTop));  }  void InternalDefMacroRuleBase(LispEnvironment aEnvironment, int aStackTop, boolean aListed) throws Exception  {    // Get operator    LispPtr args = new LispPtr();    LispPtr body = new LispPtr();    String orig=null;        LispError.CHK_ARG_CORE(aEnvironment,aStackTop,YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get() != null, 1);    orig = YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get().String();    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1);    // The arguments    args.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 2).Get());    LispError.CHK_ISLIST_CORE(aEnvironment,aStackTop,args,2);    // Finally define the rule base    aEnvironment.DeclareMacroRuleBase(LispStandard.SymbolName(aEnvironment,orig),                                 args.Get().SubList().Get().Next(),aListed);        // Return true    LispStandard.InternalTrue(aEnvironment,YacasEvalCaller.RESULT(aEnvironment, aStackTop));  }  public void InternalNewRulePattern(LispEnvironment aEnvironment, int aStackTop, boolean aMacroMode) throws Exception  {    int arity;    int precedence;    LispPtr ar = new LispPtr();    LispPtr pr = new LispPtr();    LispPtr predicate = new LispPtr();    LispPtr body = new LispPtr();    String orig=null;        // Get operator    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get() != null, 1);    orig = YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get().String();    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1);    ar.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 2).Get());    pr.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 3).Get());    predicate.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 4).Get());    body.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 5).Get());        // The arity    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,ar.Get() != null, 2);    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,ar.Get().String() != null, 2);    arity = Integer.parseInt(ar.Get().String(),10);    // The precedence    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,pr.Get() != null, 3);    LispError.CHK_ARG_CORE(aEnvironment,aStackTop,pr.Get().String() != null, 3);    precedence = Integer.parseInt(pr.Get().String(),10);        // Finally define the rule base    aEnvironment.DefineRulePattern(LispStandard.SymbolName(aEnvironment,orig),                            arity,                            precedence,                            predicate,                            body );    // Return true    LispStandard.InternalTrue(aEnvironment,YacasEvalCaller.RESULT(aEnvironment, aStackTop));  }  class LispQuote extends YacasEvalCaller  {    public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception    {      RESULT(aEnvironment, aStackTop).Set(ARGUMENT(aEnvironment, aStackTop, 1).Get().Copy(false));    }  }  class LispEval extends YacasEvalCaller  {    public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception    {      aEnvironment.iEvaluator.Eval(aEnvironment, RESULT(aEnvironment, aStackTop), ARGUMENT(aEnvironment, aStackTop, 1));    }  }  class LispWrite extends YacasEvalCaller  {    public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception    {      LispPtr subList = ARGUMENT(aEnvironment, aStackTop, 1).Get().SubList();      if (subList != null)      {        LispIterator iter = new LispIterator(subList);        iter.GoNext();        while (iter.GetObject() != null)        {          aEnvironment.iCurrentPrinter.Print(iter.Ptr(),aEnvironment.iCurrentOutput,aEnvironment);          iter.GoNext();        }      }      LispStandard.InternalTrue(aEnvironment,RESULT(aEnvironment, aStackTop));    }  }  class LispWriteString extends YacasEvalCaller  {    public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception    {      LispError.CHK_ARG_CORE(aEnvironment,aStackTop,ARGUMENT(aEnvironment, aStackTop, 1).Get()!= null,1);      String str = ARGUMENT(aEnvironment, aStackTop, 1).Get().String();      LispError.CHK_ARG_CORE(aEnvironment,aStackTop,str != null,1);      LispError.CHK_ARG_CORE(aEnvironment,aStackTop,str.charAt(0) == '\"',1);      LispError.CHK_ARG_CORE(aEnvironment,aStackTop,str.charAt(str.length()-1) == '\"',1);      int i=1;      int nr=str.length()-1;      //((*str)[i] != '\"')      for (i=1;i<nr;i++)      {        aEnvironment.iCurrentOutput.PutChar(str.charAt(i));      }      // pass last printed character to the current printer      aEnvironment.iCurrentPrinter.RememberLastChar(str.charAt(nr-1));	// hacky hacky      LispStandard.InternalTrue(aEnvironment,RESULT(aEnvironment, aStackTop));    }  }  class LispFullForm extends YacasEvalCaller  {    public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception    {      RESULT(aEnvironment, aStackTop).Set(ARGUMENT(aEnvironment, aStackTop, 1).Get());      LispPrinter printer = new LispPrinter();      printer.Print(RESULT(aEnvironment, aStackTop), aEnvironment.iCurrentOutput, aEnvironment);      aEnvironment.iCurrentOutput.Write("\n");    }  }  class LispDefaultDirectory extends YacasEvalCaller  {    public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception    {      // Get file name      LispError.CHK_ARG_CORE(aEnvironment,aStackTop,ARGUMENT(aEnvironment, aStackTop, 1).Get() != null, 1);      String orig = ARGUMENT(aEnvironment, aStackTop, 1).Get().String();      LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1);      String oper = LispStandard.InternalUnstringify(orig);      aEnvironment.iInputDirectories.add(oper);      LispStandard.InternalTrue(aEnvironment,RESULT(aEnvironment, aStackTop));    }  }  class LispDllDirectory extends YacasEvalCaller  {    public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception    {      aEnvironment.iCurrentOutput.Write("Function not yet implemented : DllDirectory");//TODO fixme      throw new Yacasexception("Function not yet supported");    }  }  class LispFromFile extends YacasEvalCaller  {    public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception    {      LispError.CHK_CORE(aEnvironment, aStackTop,aEnvironment.iSecure == false, LispError.KLispErrSecurityBreach);      LispPtr evaluated = new LispPtr();      aEnvironment.iEvaluator.Eval(aEnvironment, evaluated, ARGUMENT(aEnvironment, aStackTop, 1));      // Get file name      LispError.CHK_ARG_CORE(aEnvironment,aStackTop,evaluated.Get() != null, 1);      String orig = evaluated.Get().String();      LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1);      String hashedname = aEnvironment.HashTable().LookUpUnStringify(orig);      InputStatus oldstatus = aEnvironment.iInputStatus;      LispInput previous = aEnvironment.iCurrentInput;      try      {        aEnvironment.iInputStatus.SetTo(hashedname);        LispInput input = // new StdFileInput(hashedname, aEnvironment.iInputStatus);          LispStandard.OpenInputFile(aEnvironment, aEnvironment.iInputDirectories, hashedname, aEnvironment.iInputStatus);        aEnvironment.iCurrentInput = input;        // Open file        LispError.CHK_CORE(aEnvironment, aStackTop,input != null, LispError.KLispErrFileNotFound);        // Evaluate the body        aEnvironment.iEvaluator.Eval(aEnvironment, RESULT(aEnvironment, aStackTop), ARGUMENT(aEnvironment, aStackTop, 2));      }      catch (Exception e)      {        throw e;      }      finally      {        aEnvironment.iCurrentInput = previous;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -