Closed
Description
Searching in a list can be expressed via lib-1.2 as
search : ∀ {p} {P : Pred A p} → Decidable P → (xs : List A) →
(∃ (\x → P x)) ⊎ (¬ Any P xs)
search P? xs with any P? xs
... | yes anyP-xs = inj₁ (satisfied anyP-xs)
... | no ¬anyP-xs = inj₂ ¬anyP-xs
First, is there a ready function in lib-1.2 to express this?
Second, it is more desirable to have (for a setoid)
search : ∀ {p} {P : Pred A p} → Decidable P → (xs : List A) →
(∃ (\x → x ∈ xs × P x)) ⊎ (¬ Any P xs)
Has lib-1.2 something for this?