简体   繁体   English

使用TI-Nspire数学库中的eval函数

[英]using the eval function in the TI-Nspire math library

I am trying to understand how to use the TI-Nspire CAS system through Lua. 我试图了解如何通过Lua使用TI-Nspire CAS系统。 I am trying to emulate the solve(x+5/3,x) functionality found in the TI-Nspire CX CAS gui. 我试图模仿TI-Nspire CX CAS gui中的solve(x+5/3,x)功能。

I looked through the API Docs found here : https://education.ti.com/download/en/ed-tech/59108CCE54484B76AF68879C217D47B2/7EFB09CED41C4190AFF8F60283B6727A/TI-NspireLuaScriptingAPIReferenceGuide.pdf 我浏览了这里找到的API文档: https//education.ti.com/download/en/ed-tech/59108CCE54484B76AF68879C217D47B2/7EFB09CED41C4190AFF8F60283B6727A/TI-NspireLuaScriptingAPIReferenceGuide.pdf

I believe what I am looking for is the eval function on page 51 although I can't find much online to sample from. 我相信我正在寻找的是第51页的eval函数,尽管我找不到很多在线样本。 The examples provided are not concrete ones. 提供的示例不是具体的示例。

math.eval(math_expression) --apilevel = 2.0
math.eval(math_expression, [exact]) --apilevel = 1.0
local expr = "f1("..mx")"
return math.eval(expr)

Iv'e tried 我试过了

require "math"
local answer
answer = math.eval("f1(x+3/4,x)")
answer = math.eval(x+3/4,x)
answer = math.eval("5+9")

I keep getting the error "cannot execute during initialization." 我一直收到错误“无法在初始化期间执行”。

1) How do you fix the error 1)如何修复错误

2) May I have some concrete examples of using the function 2)我可以有一些使用该功能的具体例子

From the TI-Nspire Lua Scripting API Reference Manual 12.1 math.eval : 来自TI-Nspire Lua Scripting API参考手册12.1 math.eval

Warning 警告

math.eval is not available during script initialization 在脚本初始化期间,math.eval不可用

To avoid this error do not call the function befor script is initialized. 为避免此错误,请不要调用函数befor脚本进行初始化。

This works! 这有效!

function on.paint(gc)
    local var1
    var1 = math.eval("nsolve(x+4=8,x)")
    gc:drawString(var1, 2, 20)
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM