0
convert(file.ext,string)

根据使用的 Maple 当前版本给出不同的结果。在 Maple v14 中给出“file.ext”,但在 Maple v15 中给出“file.ext”(点前后有空格)。有人可以解释一下吗?提前致谢。

4

1 回答 1

1

是的,有区别,但更重要的是,以这种方式形成字符串的方法是错误的。

command 没有特殊的(延迟的)求值规则convert,并且该例程在这里视为第一个参数的是 namefile与 name的(非对易)乘法的结果ext。所以这并不是连接字符串的好方法,因为它的目的不是首先仔细连接。

有替代方案。您可以连接到单个名称,然后将其转换为字符串,或者您可以直接连接到字符串(命令 convert/string 不是最好的)。

 # I'm supposing that one does want the name`file` assigned
 file:=myproject:

 # Now suppose that one wants the result "myproject.for"
 ext:=`for`:

 convert(file.ext,string); # whoops
                  "myproject . `for`"

 cat(file,".",ext); # produces the name `myproject.for`
                     myproject.for

 convert(%,string);
                    "myproject.for"

 sprintf("%a.%s",file,ext);
                    "myproject.for"
于 2012-04-02T00:30:30.307 回答