2

I am trying to evaluate some code inside a block in Maxima but it does not seem to be working. If I want have something of the form

block( load("my_file.mac"), do_stuff )

it does not seem to load the file. I wanted to circumvent this problem by defining the only thing I need from that file in the following way

block( "implies"(p, q) := not p or q, infix("implies"), expr: p implies q, do_other_stuff)

But again, I get an error that implies is not an infix operator. I think this is because both load and infix have a return value (done and implies respectively in my case) which somehow corrupts the block.

It is absolutely necessary that either the entire Maxima code is contained inside a block. So although both

load("my_file.mac"); block(do_stuff)

and

"implies"(p, q) := not p or q; infix("implies"); block(expr: p implies q, do_other_stuff)

work. This is not an option for me.

4

1 回答 1

1

在评估之前解析所有块。所以如果块说类似

block (load ("my_file.mac"), p implies q);

那么“暗示”必须在解析块之前定义——它不能在块中定义。

请注意,运算符定义在 Maxima 中是全局的。如果你写block(infix("implies"), ...),那么“暗示”仍然是一个全局定义;它不限于定义它的块。

也许你可以多说一些你想要达到的目标。

于 2020-05-11T14:30:11.673 回答