mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-19 09:12:34 +03:00
16 lines
460 B
Idris
16 lines
460 B
Idris
%hide List.filter
|
|
|
|
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)
|