英文:
Maxima: check if expression is defined
问题
我想测试某些表达式是否已定义,而不会使程序停止。
例如,如果我有两个矩阵:
我知道这两个矩阵的乘积(A*B)是没有定义的。所以我希望Maxima能够在不中断要测试的更多表达式的评估的情况下打印出这个乘积未定义的信息。
英文:
I want to test wether certain expressions are deifned, without having the programm to be stoped.
For example, if have two matrices:
I know that the product (A*B) of these two is not well defined. So i would like to have maxima print out that this product is not defined without interrupting the evaluation of more expression that are to be tested.
答案1
得分: 1
也许你对errcatch
函数感兴趣,它评估表达式并在没有错误时返回结果,但如果发生错误则返回一个空列表。
要实现你想要的功能,你需要多做一些工作,但至少Maxima不会在出现错误时停止。
英文:
Perhaps you are interested in the errcatch
function that evaluates expressions and returns the results if there are no errors but returns an empty list if some error occurred.
You'll have to do a bit more work to do what you want, but at least Maxima won't stop on an error.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论