📄 mathcommands.java
字号:
"PatchString"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispDllLoad(),1, YacasEvaluator.Fixed|YacasEvaluator.Function), "DllLoad"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispDllUnload(),1, YacasEvaluator.Fixed|YacasEvaluator.Function), "DllUnload"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispDllEnumerate(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "DllEnumerate"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispSetExtraInfo(),2, YacasEvaluator.Fixed|YacasEvaluator.Function), "SetExtraInfo"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispGetExtraInfo(),1, YacasEvaluator.Fixed|YacasEvaluator.Function), "GetExtraInfo"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispDefaultTokenizer(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "DefaultTokenizer"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispCommonLispTokenizer(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "CommonLispTokenizer"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispCTokenizer(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "CTokenizer"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispXmlTokenizer(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "XmlTokenizer"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispExplodeTag(),1, YacasEvaluator.Fixed|YacasEvaluator.Function), "XmlExplodeTag"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispFastAssoc(),2, YacasEvaluator.Fixed|YacasEvaluator.Function), "FastAssoc"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispCurrentFile(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "CurrentFile"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispCurrentLine(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "CurrentLine"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispBackQuote(),1, YacasEvaluator.Fixed|YacasEvaluator.Macro), "`"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispDumpBigNumberDebugInfo(),1, YacasEvaluator.Fixed|YacasEvaluator.Function), "MathDebugInfo"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispInDebugMode(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "InDebugMode"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispDebugFile(),1, YacasEvaluator.Fixed|YacasEvaluator.Function), "DebugFile"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispDebugLine(),1, YacasEvaluator.Fixed|YacasEvaluator.Function), "DebugLine"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispMathLibName(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "MathLibrary"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispVersion(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "Version"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispPluginsCanBeLoaded(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "PluginsCanBeLoaded"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispPlatformOS(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "OSVersion"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispExit(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "Exit"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispExitRequested(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "IsExitRequested"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispHistorySize(),1, YacasEvaluator.Fixed|YacasEvaluator.Function), "HistorySize"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispStackSize(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "StaSiz"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispIsPromptShown(),0, YacasEvaluator.Fixed|YacasEvaluator.Function), "IsPromptShown"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispReadCmdLineString(),1, YacasEvaluator.Fixed|YacasEvaluator.Function), "ReadCmdLineString"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispTime(),1, YacasEvaluator.Fixed|YacasEvaluator.Macro), "GetTime"); aEnvironment.CoreCommands().SetAssociation( new YacasEvaluator(new LispFileSize(),1, YacasEvaluator.Fixed|YacasEvaluator.Function), "FileSize"); } /// Construct a BigNumber from one of the arguments. /// \param x (on output) the constructed bignumber /// \param aEnvironment the current environment /// \param aStackTop the index of the top of the stack /// \param aArgNr the index of the argument to be converted public static BigNumber GetNumber(LispEnvironment aEnvironment, int aStackTop, int aArgNr) throws Exception { BigNumber x = YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, aArgNr).Get().Number(aEnvironment.Precision()); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,x != null,aArgNr); return x; } static void MultiFix(LispEnvironment aEnvironment, int aStackTop, LispOperators aOps) throws Exception { // Get operator LispError.CHK_ARG_CORE(aEnvironment,aStackTop,YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get() != null, 1); String orig = YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get().String(); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1); LispPtr precedence = new LispPtr(); aEnvironment.iEvaluator.Eval(aEnvironment, precedence, YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 2)); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,precedence.Get().String() != null, 2); int prec = Integer.parseInt(precedence.Get().String(),10); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,prec <= InfixPrinter.KMaxPrecedence, 2); aOps.SetOperator(prec,LispStandard.SymbolName(aEnvironment,orig)); LispStandard.InternalTrue(aEnvironment,YacasEvalCaller.RESULT(aEnvironment, aStackTop)); } public static void SingleFix(int aPrecedence, LispEnvironment aEnvironment, int aStackTop, LispOperators aOps) throws Exception { // Get operator LispError.CHK_ARG_CORE(aEnvironment,aStackTop,YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get() != null, 1); String orig = YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get().String(); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1); aOps.SetOperator(aPrecedence,LispStandard.SymbolName(aEnvironment,orig)); LispStandard.InternalTrue(aEnvironment,YacasEvalCaller.RESULT(aEnvironment, aStackTop)); } public static LispInFixOperator OperatorInfo(LispEnvironment aEnvironment,int aStackTop, LispOperators aOperators) throws Exception { // Get operator LispError.CHK_ARG_CORE(aEnvironment,aStackTop,YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get() != null, 1); LispPtr evaluated = new LispPtr(); evaluated.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get()); String orig = evaluated.Get().String(); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1); // LispInFixOperator op = (LispInFixOperator)aOperators.LookUp(LispStandard.SymbolName(aEnvironment,orig)); return op; } /// Execute the Yacas commands \c Set and \c MacroSet. /// The argument \a aMacroMode determines whether the first argument /// should be evaluated. The real work is done by /// LispEnvironment::SetVariable() . /// \sa LispSetVar(), LispMacroSetVar() static void InternalSetVar(LispEnvironment aEnvironment, int aStackTop, boolean aMacroMode) throws Exception { String varstring=null; if (aMacroMode) { LispPtr result = new LispPtr(); aEnvironment.iEvaluator.Eval(aEnvironment, result, YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1)); varstring = result.Get().String(); } else { varstring = YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get().String(); } LispError.CHK_ARG_CORE(aEnvironment,aStackTop,varstring != null,1); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,!LispStandard.IsNumber(varstring,true),1); LispPtr result = new LispPtr(); aEnvironment.iEvaluator.Eval(aEnvironment, result, YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 2)); aEnvironment.SetVariable(varstring, result); LispStandard.InternalTrue(aEnvironment,YacasEvalCaller.RESULT(aEnvironment, aStackTop)); } public static void InternalDelete(LispEnvironment aEnvironment, int aStackTop, boolean aDestructive) throws Exception { LispPtr evaluated = new LispPtr(); evaluated.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get()); LispError.CHK_ISLIST_CORE(aEnvironment,aStackTop,evaluated,1); LispPtr copied = new LispPtr(); if (aDestructive) { copied.Set(evaluated.Get().SubList().Get()); } else { LispStandard.InternalFlatCopy(copied,evaluated.Get().SubList()); } LispPtr index = new LispPtr(); index.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 2).Get()); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,index.Get() != null, 2); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,index.Get().String() != null, 2); int ind = Integer.parseInt(index.Get().String(),10); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,ind>0,2); LispIterator iter = new LispIterator(copied); while (ind>0) { iter.GoNext(); ind--; } LispError.CHK_CORE(aEnvironment, aStackTop,iter.GetObject() != null, LispError.KLispErrListNotLongEnough); LispPtr next = new LispPtr(); next.Set(iter.GetObject().Next().Get()); iter.Ptr().Set(next.Get()); YacasEvalCaller.RESULT(aEnvironment, aStackTop).Set(LispSubList.New(copied.Get())); } public static void InternalInsert(LispEnvironment aEnvironment, int aStackTop, boolean aDestructive) throws Exception { LispPtr evaluated = new LispPtr(); evaluated.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get()); LispError.CHK_ISLIST_CORE(aEnvironment,aStackTop,evaluated,1); LispPtr copied = new LispPtr(); if (aDestructive) { copied.Set(evaluated.Get().SubList().Get()); } else { LispStandard.InternalFlatCopy(copied,evaluated.Get().SubList()); } LispPtr index = new LispPtr(); index.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 2).Get()); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,index.Get() != null, 2); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,index.Get().String() != null, 2); int ind = Integer.parseInt(index.Get().String(),10); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,ind>0,2); LispIterator iter = new LispIterator(copied); while (ind>0) { iter.GoNext(); ind--; } LispPtr toInsert = new LispPtr(); toInsert.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 3).Get()); toInsert.Get().Next().Set(iter.GetObject()); iter.Ptr().Set(toInsert.Get()); YacasEvalCaller.RESULT(aEnvironment, aStackTop).Set(LispSubList.New(copied.Get())); } public static void InternalReplace(LispEnvironment aEnvironment, int aStackTop, boolean aDestructive) throws Exception { LispPtr evaluated = new LispPtr(); evaluated.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 1).Get()); // Ok, so lets not check if it is a list, but it needs to be at least a 'function' LispError.CHK_ARG_CORE(aEnvironment,aStackTop,evaluated.Get().SubList() != null, 1); LispPtr index = new LispPtr(); index.Set(YacasEvalCaller.ARGUMENT(aEnvironment, aStackTop, 2).Get()); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,index.Get() != null, 2); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,index.Get().String() != null, 2); int ind = Integer.parseInt(index.Get().String(),10); LispPtr copied = new LispPtr(); if (aDestructive) { copied.Set(evaluated.Get().SubList().Get()); } else { LispStandard.InternalFlatCopy(copied,evaluated.Get().SubList()); } LispError.CHK_ARG_CORE(aEnvironment,aStackTop,ind>0,2); LispIterator iter = new LispIterator(copied); while (ind>0) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -