我想创建一个可以在2个不同的表达式变量中存储implies()函数的左右参数的函数。 带有代码的解决方案非常有价值。 谢谢。
这是我以前尝试过的东西。
// Open and close ctls.
this.DOM.openCtrl = this.DOM.el.querySelector('.action--menu');
this.DOM.closeCtrl = this.DOM.el.querySelector('.action--close');
this.DOM.ItemcloseCtrl1 = this.DOM.el.querySelector('.item--close1');
this.DOM.ItemcloseCtrl2 = this.DOM.el.querySelector('.item--close2');
this.DOM.ItemcloseCtrl3 = this.DOM.el.querySelector('.item--close3');
this.DOM.ItemcloseCtrl4 = this.DOM.el.querySelector('.item--close4');
this.DOM.ItemcloseCtrl5 = this.DOM.el.querySelector('.item--close5');
this.DOM.openCtrl.addEventListener('click', () => this.open());
this.DOM.closeCtrl.addEventListener('click', () => this.close());
this.DOM.ItemcloseCtrl1.addEventListener('click', () => this.close());
this.DOM.ItemcloseCtrl2.addEventListener('click', () => this.close());
this.DOM.ItemcloseCtrl3.addEventListener('click', () => this.close());
this.DOM.ItemcloseCtrl4.addEventListener('click', () => this.close());
this.DOM.ItemcloseCtrl5.addEventListener('click', () => this.close());
这是输出:
#include<iostream>
#include<string>
#include "z3++.h"
using namespace z3;
using namespace std;
void walk(int tab, expr e)
{
string blanks(tab, ' ');
if(e.is_const())
{
cout << blanks << "ARGUMENT: " << e << endl;
}
else
{
cout << blanks << "APP: " << e.decl().name() << endl;
for(int i = 0; i < e.num_args(); i++)
{
walk(tab + 5, e.arg(i));
}
}
}
int main()
{
context c;
expr x = c.bool_const("x");
expr y = c.bool_const("y");
expr z = c.bool_const("z");
expr e = implies(z,(x && y));
walk(0, e);
}
答案 0 :(得分:1)
我将通过一个示例来表达我的评论
if (e.is_implies()) {
cout << "left side: " <<endl;
walk(4, e.arg(0));
cout << "right side: " <<endl;
walk(4, e.arg(1));
}
这使用is_implies
类的arg
和expr
方法。 documentation