为什么 Adam Chlipala 使用左关联嵌套元组来表示 CPDT 中的 Ltac 列表?
Why does Adam Chlipala use left-associated nested tuples to represent Ltac lists in CPDT?
[...] Succeed iff x
is in the list ls
, represented with left-associated nested tuples.
Ltac inList x ls :=
match ls with
| x => idtac
| (_, x) => idtac
| (?LS, _) => inList x LS
end.
这似乎不典型。按照惯例,列表的尾部不是放在元组的右侧吗?
通过与 Adam 的私人通信:
No, I can't think of any way to prefer one version over the other,
actually. I just had to make some choice for that part of the book.
n 元组不知何故是与左侧关联的嵌套对:
(x, y, z)
脱糖为
pair (pair x y) z
这就是我们想要写的 inList x (x, y, z)
。
[...] Succeed iff
x
is in the listls
, represented with left-associated nested tuples.
Ltac inList x ls := match ls with | x => idtac | (_, x) => idtac | (?LS, _) => inList x LS end.
这似乎不典型。按照惯例,列表的尾部不是放在元组的右侧吗?
通过与 Adam 的私人通信:
No, I can't think of any way to prefer one version over the other, actually. I just had to make some choice for that part of the book.
n 元组不知何故是与左侧关联的嵌套对:
(x, y, z)
脱糖为
pair (pair x y) z
这就是我们想要写的 inList x (x, y, z)
。