Idris2/tests/idris2/with006/SparseWith.idr
Guillaume ALLAIS a7d73d0d3d [ new ] ellipses for with patterns
Rather than Agda's `...` we use the common symbol for "I don't care": `_`.
2021-08-31 22:50:46 +01:00

14 lines
441 B
Idris

filter : (p : a -> Bool) -> List a -> List a
filter p [] = []
filter p (x :: xs) with (p x)
_ | True = x :: filter p xs
_ | False = filter p xs
filterFilter : (p : a -> Bool) -> (xs : List a) ->
filter p (filter p xs) === filter p xs
filterFilter p [] = Refl
filterFilter p (x :: xs) with (p x) proof eq
_ | False = filterFilter p xs
_ | True with (p x)
_ | True = cong (x ::) (filterFilter p xs)