From eacb437f437bc79650708af472b7796c7fd041e5 Mon Sep 17 00:00:00 2001 From: bringert Date: Mon, 20 Mar 2006 14:46:47 +0000 Subject: Expermintation woth a collections framework for transfer. --- transfer/lib/vector.tra | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 transfer/lib/vector.tra (limited to 'transfer/lib/vector.tra') 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) -- cgit v1.2.3