Skip to content

Commit b6c7856

Browse files
authored
Add function to reduce All into Vec (#1263)
1 parent ebeb3be commit b6c7856

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,11 @@ Other minor additions
497497
transpose : ∀ {m n} → Vector (Vector A n) m → Vector (Vector A m) n
498498
```
499499

500+
* Added new functions to `Data.Vec.Relation.Unary.All`:
501+
```agda
502+
reduce : (f : ∀ {x} → P x → B) → All P xs → Vec B n
503+
```
504+
500505
* Added new proofs to `Data.Vec.Relation.Unary.All.Properties`:
501506
```agda
502507
All-swap : ∀ {xs ys} → All (λ x → All (x ~_) ys) xs → All (λ y → All (_~ y) xs) ys

src/Data/Vec/Relation/Unary/All.agda

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ module _ {P : Pred A p} where
4747
tail : {n x} {xs : Vec A n} All P (x ∷ xs) All P xs
4848
tail (px ∷ pxs) = pxs
4949

50+
reduce : (f : {x} P x B) {n} {xs : Vec A n} All P xs Vec B n
51+
reduce f [] = []
52+
reduce f (px ∷ pxs) = f px ∷ reduce f pxs
53+
5054
uncons : {n x} {xs : Vec A n} All P (x ∷ xs) P x × All P xs
5155
uncons = < head , tail >
5256

0 commit comments

Comments
 (0)