This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _contains_ : {A : Set} → List A → (A → Bool) → Bool | |
| [] contains _ = false | |
| (x :: xs) contains p = (p x) || (xs contains p) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _:+_ : {A : Set} → {n : ℕ} → A → Vec A n → Vec A (succ n) | |
| a :+ [] = a :: [] | |
| a :+ (x :: xs) = x :: (a :+ xs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| zipop : {A : Set} → {n : ℕ} → Vec A n → Vec A n → (A → A → A) → Vec A n | |
| zipop [] [] _ = [] | |
| zipop (x :: xs) (y :: ys) op = (op x y) :: (zipop xs ys op) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| countdown : (n : ℕ) → Vec ℕ (succ n) | |
| countdown zero = zero :: [] | |
| countdown (succ m) = (succ m) :: (countdown m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data Vec (A : Set) : ℕ → Set where | |
| [] : Vec A zero | |
| _::_ : {n : ℕ} → A → Vec A n → Vec A (succ n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _flatMap_ : {A B : Set} → List A → (A → List B) → List B | |
| [] flatMap _ = [] | |
| (a :: xs) flatMap f = (f a) ++ (xs flatMap f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _map_ : {A B : Set} → List A → (A → B) → List B | |
| [] map _ = [] | |
| (a :: xs) map f = (f a) :: (xs map f) | |
| twothreefour : List ℕ | |
| twothreefour = onetwothree map succ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _++_ : {A : Set} → List A → List A → List A | |
| [] ++ l = l | |
| (a :: xs) ++ l = a :: (xs ++ l) | |
| reverse : {A : Set} → List A → List A | |
| reverse [] = [] | |
| reverse (a :: l) = (reverse l) ++ (a :: []) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| length : {A : Set} → List A → ℕ | |
| length [] = zero | |
| length (a :: l) = succ (length l) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| length₀ : (A : Set) → List A → ℕ | |
| length₀ _ [] = zero | |
| length₀ A (a :: l) = succ (length₀ A l) |