mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-17 00:10:31 +03:00
a7d73d0d3d
Rather than Agda's `...` we use the common symbol for "I don't care": `_`.
14 lines
441 B
Idris
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)
|