Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 获取运算符操作数_List_Prolog_Operators - Fatal编程技术网

List 获取运算符操作数

List 获取运算符操作数,list,prolog,operators,List,Prolog,Operators,我有一份清单: List = [a=3, b=2, c=0]. 例如,第一个元素a=3,如何获取左=a,右=3。 左边是原子,右边是数字。使用统一: ?- List = [a=3, b=2, c=0], member(Left=Right, List). List = [a=3, b=2, c=0], Left = a, Right = 3 ; List = [a=3, b=2, c=0], Left = b, Right = 2 ; List = [a=3, b=2, c=0], Left

我有一份清单:

List = [a=3, b=2, c=0].
例如,第一个元素
a=3
,如何获取左=
a
,右=
3
。 左边是原子,右边是数字。

使用统一:

?- List = [a=3, b=2, c=0], member(Left=Right, List). List = [a=3, b=2, c=0], Left = a, Right = 3 ; List = [a=3, b=2, c=0], Left = b, Right = 2 ; List = [a=3, b=2, c=0], Left = c, Right = 0.
换句话说,是的,
=
被声明为操作符,但它也是一个原子,因此它可以是一个术语的名称。

希望你和我一样喜欢答案末尾的
。 ?- write_canonical(a=3). =(a,3) true.