In Prolog, [a, b, c] = [a, b, c | []]
However, I am confused about what the head of [a, b, c | []] is? If [a, b, c] = [a, b, c | []] why is it not true that: [a, b, c] = [a, b, c | []] = [[a, b, c | []] | []]] = ... (so I added another empty list at the end of the head, since they are elements separated by a comma, just like it is the case with [a, b, c] where we also added an empty list)
So I see a comma as: combine all the elements via the | operator, and add an empty list at the end. "a, b, c" (the head of [a, b, c | []]) would then become [a, b, c | []] again and so on.
但是,我的解释是错误的,因为我刚才所说的话是错误的。
And If I m not mistaken, | has a higher precedence than the comma operator. So [A, B|C] = [A|[B|C]]. But why is it not the case that [A, B|C] = [A|[[B|C]|[]]].
I can memorize the correct definition as follows: combine the elements via |, and add an empty list at the end only if the last operand of the commas is enclosed by a ]. So then: [a, b, c] = [a, b, c | []], and if I got [a, b, c | []], even though I got commas here, I wouldn t add an empty list since the last element (c) is not enclosed by a ]. But this seems to be not a good way to understand this.