From: Michael Orlitzky Date: Mon, 4 Feb 2013 17:31:48 +0000 (-0500) Subject: Add toList and fromList functions in FixedVector.hs. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=numerical-analysis.git;a=commitdiff_plain;h=2471e02fc847a2a7f5ee04cb0ab95b7909a99c38 Add toList and fromList functions in FixedVector.hs. --- diff --git a/src/FixedVector.hs b/src/FixedVector.hs index 0a5312a..8848b9b 100644 --- a/src/FixedVector.hs +++ b/src/FixedVector.hs @@ -170,6 +170,7 @@ angle v1 v2 = -- | Safe indexing. +-- -- Examples: -- -- >>> let v1 = make3d (1,2,3) @@ -184,6 +185,28 @@ angle v1 v2 = | otherwise = Just $ v1 ! idx +-- | Convert vector to a list. +-- +-- Examples: +-- +-- >>> let v1 = make2d (1,2) +-- >>> toList v1 +-- [1,2] +-- +toList :: (V.Vector v a) => Vn (v a) -> [a] +toList (Vn v1) = V.toList v1 + + +-- | Convert a list to a vector. +-- +-- Examples: +-- +-- >>> fromList [1,2] :: Vn (Vec2D Int) +-- (1,2) +-- +fromList :: (V.Vector v a) => [a] -> Vn (v a) +fromList xs = Vn $ V.fromList xs + -- * Two- and three-dimensional wrappers. -- -- These two wrappers are instances of 'Vector', so they inherit all