Add an 'iterate' function to Utils
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
ec31333e9a
commit
6fe8dc2a02
|
@ -1,5 +1,6 @@
|
|||
module Utils where
|
||||
|
||||
open import Data.Nat using (ℕ; suc)
|
||||
open import Data.List using (List; []; _∷_; _++_)
|
||||
open import Data.List.Membership.Propositional using (_∈_)
|
||||
open import Data.List.Relation.Unary.All using (All; []; _∷_; map)
|
||||
|
@ -34,3 +35,7 @@ All¬-¬Any {l = x ∷ xs} (_ ∷ ¬Pxs) (there Pxs) = All¬-¬Any ¬Pxs Pxs
|
|||
All-x∈xs : ∀ {a} {A : Set a} (xs : List A) → All (λ x → x ∈ xs) xs
|
||||
All-x∈xs [] = []
|
||||
All-x∈xs (x ∷ xs') = here refl ∷ map there (All-x∈xs xs')
|
||||
|
||||
iterate : ∀ {a} {A : Set a} (n : ℕ) → (f : A → A) → A → A
|
||||
iterate 0 _ a = a
|
||||
iterate (suc n) f a = f (iterate n f a)
|
||||
|
|
Loading…
Reference in New Issue
Block a user