diff options
| author | bringert <bringert@cs.chalmers.se> | 2006-03-20 14:46:47 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2006-03-20 14:46:47 +0000 |
| commit | eacb437f437bc79650708af472b7796c7fd041e5 (patch) | |
| tree | 44d21f05cf6ea4f6a52c819488a31521ad6d22d7 /transfer/lib/vector.tra | |
| parent | d760ce973896bbfd5e9f62516bb953cfeeabaf1a (diff) | |
Expermintation woth a collections framework for transfer.
Diffstat (limited to 'transfer/lib/vector.tra')
| -rw-r--r-- | transfer/lib/vector.tra | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/transfer/lib/vector.tra b/transfer/lib/vector.tra new file mode 100644 index 000000000..2eda35167 --- /dev/null +++ b/transfer/lib/vector.tra @@ -0,0 +1,15 @@ +-- NOTE: this is unfinished and untested + +import nat + +data Vector : Type -> Nat -> Type where + Empty : (A:Type) -> Vector A Zero + Cell : (A:Type) -> (n:Nat) -> A -> Vector A n -> Vector A (Succ n) + +mapV : (A:Type) -> (B:Type) -> (n:Nat) -> (A -> B) -> Vector A n -> Vector B n +mapV A B _ f (Empty _) = Empty B +mapV A B (Succ n) f (Cell _ _ x xs) = Cell B n (f x) (mapV A B n f xs) + +appendV : (A:Type) -> (n:Nat) -> (m:Nat) -> Vector A n -> Vector A m -> Vector A (plusNat n m) +appendV A _ _ (Empty _) ys = ys +appendV A (Succ n) m (Cell _ _ x xs) ys = appendV A n (Succ m) xs (Cell A m x ys) |
