MLPutFunction()

int MLPutFunction(MLINK link, const char *s, int n)
把一个标头由名称为 s,并带有 n 个自变量的符号给定的函数写入由 link 指定的 MathLink 连接.

更多信息更多信息

  • 在调用 MLPutFunction() 之后,必须调用其他 MathLink 函数传递函数的自变量.
  • MLPutFunction() 在错误事件中返回0,如果函数成功则返回非零值.
  • 如果 MLPutFunction() 失败,则使用 MLError() 检索错误代码.
  • MLPutFunction()MathLink 标头文件 mathlink.h 中被声明.

范例范例打开所有单元关闭所有单元

基本范例 (1)基本范例 (1)

#include "mathlink.h"

/* put an Integrate[] expression to a link */

void f(MLINK lp)
{
    if(! MLPutFunction(lp, "Integrate", 2))
        { /* unable to put the function to lp */ }

    if(! MLPutFunction(lp, "Times", 2))
        { /* unable to put the function to lp */ }

    if(! MLPutFunction(lp, "Power", 2))
        { /* unable to put the function to lp */ }

    if(! MLPutSymbol(lp, "x", 1))
        { /* unable to put the symbol to lp */ }

    if( ! MLPutInteger(lp, 2))
        { /* unable to put the integer to lp */ }

    if(! MLPutFunction(lp, "Power", 2))
        { /* unable to put the function to lp */ }

    if(! MLPutFunction(lp, "Sqrt", 1))
        { /* unable to put the function to lp */ }

    if(! MLPutSymbol(lp, "x", 1))
        { /* unable to put the symbol to lp */ }

    if(! MLPutInteger(lp, -1))
        { /* unable to put the integer to lp */ }

    if(! MLPutSymbol(lp, "x", 1))
        { /* unable to put the symbol to lp */ }

    if(! MLEndPacket(lp))
        { /* unable to send the end-of-packet sequence to lp */ }

    if(! MLFlush(lp))
        { /* unable to flush any buffered output data in lp */ }
}
New to Mathematica? Find your learning path »
Have a question? Ask support »