Tutorial by Examples

The Data.Vector module provided by the vector is a high performance library for working with arrays. Once you've imported Data.Vector, it's easy to start using a Vector: Prelude> import Data.Vector Prelude Data.Vector> let a = fromList [2,3,4] Prelude Data.Vector> a fromList [2,3,4]...
Filter odd elements: Prelude Data.Vector> Data.Vector.filter odd y fromList [1,3,5,7,9,11] :: Data.Vector.Vector
Vectors can be map'd and fold'd,filter'd andzip`'d: Prelude Data.Vector> Data.Vector.map (^2) y fromList [0,1,4,9,16,25,36,49,64,81,100,121] :: Data.Vector.Vector Reduce to a single value: Prelude Data.Vector> Data.Vector.foldl (+) 0 y 66
Zip two arrays into an array of pairs: Prelude Data.Vector> Data.Vector.zip y y fromList [(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11)] :: Data.Vector.Vector

Page 1 of 1