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
| 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
| 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
| _:+_ : {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
| _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
| if_then_else : {A : Set} → Bool → A → A → A | |
| if true then x else _ = x | |
| if false then _ else y = y |
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
| _filter_ : {A : Set} → List A → (A → Bool) → List A | |
| [] filter _ = [] | |
| (x :: xs) filter p = if (p x) then (x :: (xs filter p)) else (xs filter 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
| fold_by_from_ : {A : Set} → {B : Set} → List A → (A → B → B) → B → B | |
| fold [] by _ from b = b | |
| fold (x :: xs) by op from b = op x (fold xs by op from b) |
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
| open import Nat | |
| upto : ℕ → List ℕ | |
| upto zero = [] | |
| upto (succ n) = (upto n) ++ ((succ n) :: []) | |
| listsqs : ℕ → List ℕ | |
| listsqs n = upto n map (λ x → (x * x)) | |
| sumsqs : ℕ → ℕ |
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 Option (A : Set) : Set where | |
| Some : A → Option A | |
| None : Option A |