评论者:pbrown
我遇到了另一种额外的嵌套情况,在重复一个或多个序列时,如果该序列的起始或结束处有一个可选的元素,且该元素的谓词也匹配另一端的元素时
user=> (s/conform (s/+ (s/cat :k any? :v (s/? any?))) [:a 1 :b 2]) [{:k :a, :v 1} [{:k :b, :v 2}]]
我期望得到
`
[{:k :a, :v 1} {:k :b, :v 2}] `
以下代码给出了期望的结果
user=> (s/conform (s/+ (s/cat :k any? :v (s/? any?))) [:a 1 :b]) [{:k :a, :v 1} {:k :b}] user=> (s/conform (s/+ (s/cat :k keyword? :v (s/? int?))) [:a 1 :b 2]) [{:k :a, :v 1} {:k :b, :v 2}] user=> (s/conform (s/* (s/cat :k any? :v (s/? any?))) [:a 1 :b 2]) [{:k :a, :v 1} {:k :b, :v 2}]