maple - 如何将枫树表达式转换为python代码?
问题描述
有没有比 Maple 中提供的 convert 函数更好的方法将 Maple 表达式转换为 Python(这似乎根本不起作用)
convert(9 + x, python)
Error, (in convert/python) cannot convert to python
解决方案
如果您尝试从某个 Maple 表达式生成 python 源代码,请查看CodeGeneration
包。
例如,
CodeGeneration[Python]( 9+x );
cg0 = 9 + x
还有一个,
func := proc(x) local y; y:=9+arcsin(x) end proc:
CodeGeneration[Python]( func );
import math
def func (x):
y = 9 + math.asin(x)
return(y)
该convert(...,python)
语法用于将某些类型的 Maple 表达式转换为可与(有限的)python 运行时仿真一起使用的替代内部表示。但是您已经描述了生成python“代码”,我认为它是指用于导出的源代码。
推荐阅读
- excel - VBA:将参考左侧的行中的值相加
- java - 通过从组合框中选择项目来更改 textArea 字体
- android - Firebase:如何实现“仅当另一台设备在线时才采取行动”?
- python - 瑞利测试,从函数中只得到一个答案(Python3)
- sinon - Sinon 存根返回 false
- git - 如何将 Git 索引作为文本操作(转储和加载)?
- winforms - Powershell 中的 Windows 窗体,从多个列表视图/框中选择
- node.js - npm 全局安装 package.json 文件
- kendo-ui - 具有值的列的 Kendo 网格列模板
- python-3.x - 如何在 python 3 中组合 '"+variable+"'