Skip to content

searching in list #989

Closed
Closed
@mechvel

Description

@mechvel

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions