-
Notifications
You must be signed in to change notification settings - Fork 247
Add delete
to Data.List.Base
?
#988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
@mechvel as always feel free to open a PR. |
Cf. #989 module _ (P? : Decidable P) where
private
helper : ∀ xs → All (∁ P) xs ⊎ Any P xs
helper = All.decide (Sum.swap ∘ (Dec.toSum ∘ P?))
delete : List _ → List _
delete xs with helper xs
... | inj₁ _ = xs
... | inj₂ p = xs Any.─ p But it's not clear (to me, at least) which, if any, of |
Personally I do not know. Currently I use my home-made functions
If the standard library announces an adequate replacement for them, then I would use the standard functions.
and some others. |
You should find (and be able to prove ;-)) that this is extensionally equivalent to |
First, this
Is this |
Sorry, |
I would be happy to have As @jamesmckinna says, @jamesmckinna I'm not so keen on your version of |
Let the team decide. |
Agree with @MatthewDaggitt that
deleteFirst : (P? : Decidable P) → List A → List A
-- Delete the first x in xs such that P x, or return xs if there is not such x.
deleteFirst _ [] = []
deleteFirst P? (x ∷ xs) with does (P? x)
... | true = xs
... | false = x ∷ (deleteFirst P? xs) |
Following jamesmckinna, I consider replacing my
But I see now that
Because the latter takes n steps in the above example, and the function |
Consider
What standard library has for this?
The text was updated successfully, but these errors were encountered: