|
ForSyDe.Shallow.Vector | Portability | portable | Stability | experimental | Maintainer | forsyde-dev@ict.kth.se |
|
|
|
Description |
This module defines the data type Vector and the
corresponding functions. It is a development of the module
defined by Reekie. Though the vector is modeled as a list, it
should be viewed as an array, i.e. a vector has a fixed
size. Unfortunately, it is not possible to have the size of the
vector as a parameter of the vector data type, due to restrictions
in Haskells type system. Still most operations are defined for
vectors with the same size.
|
|
Synopsis |
|
|
|
Documentation |
|
|
The data type Vector is modeled similar to a list. It has two data type constructors. NullV constructs the empty vector, while ':>' constructsa vector by adding an value to an existing vector. Using the inheritance mechanism of Haskell we have declared Vector as an instance of the classes Read and Show.
| This means that the vector 1:>2:>3:>NullV is shown as 1,2,3.
| Constructors | | Instances | |
|
|
|
The function vector converts a list into a vector.
|
|
|
The function fromVector converts a vector into a list.
|
|
|
The function unitV creates a vector with one element.
|
|
|
The function nullV returns True if a vector is empty.
|
|
|
The function lengthV returns the number of elements in a value.
|
|
|
The function atV returns the n-th element in a vector, starting from zero.
|
|
|
The function replaceV replaces an element in a vector.
|
|
|
The functions headV returns the first element of a vector.
|
|
|
The functions tailV returns all, but the first element of a vector.
|
|
|
The function lastV returns the last element of a vector.
|
|
|
The function initV returns all but the last elements of a vector.
|
|
|
The function takeV returns the first n elements of a vector.
|
|
|
The function dropV drops the first n elements of a vector.
|
|
|
The function selectV selects elements in the vector. The first argument gives the initial element, starting from zero, the second argument gives the stepsize between elements and the last argument gives the number of elements.
|
|
|
The function groupV groups a vector into a vector of vectors of size n.
|
|
|
The operator '(+)' concatinates two vectors.
|
|
|
The operator '(<:)' adds an element at the end of a vector.
|
|
|
The higher-order function mapV applies a function on all elements of a vector.
|
|
|
The higher-order functions foldlV folds a function from the right to the left over a vector using an initial value.
|
|
|
The higher-order functions foldrV folds a function from the left to the right over a vector using an initial value.
|
|
|
The higher-order function zipWithV applies a function pairwise on to vectors.
|
|
|
The higher-function filterV takes a predicate function and a vector and creates a new vector with the elements for which the predicate is true.
|
|
|
The function zipV zips two vectors into a vector of tuples.
|
|
|
The function unzipV unzips a vector of tuples into two vectors.
|
|
|
The function concatV transforms a vector of vectors to a single vector.
|
|
|
The function reverseV reverses the order of elements in a vector.
|
|
|
The function shiftlV shifts a value from the left into a vector.
|
|
|
The function shiftrV shifts a value from the right into a vector.
|
|
|
The function rotrV rotates a vector to the right. Note that this fuction does not change the size of a vector.
|
|
|
The function rotlV rotates a vector to the left. Note that this fuctions does not change the size of a vector.
|
|
|
The function generateV behaves in the same way, but starts with the application of the supplied function to the supplied value.
Vector> generateV 5 (+1) 1
<2,3,4,5,6> :: Vector Integer
|
|
|
The function iterateV generates a vector with a given number of elements starting from an initial element using a supplied function for the generation of elements.
Vector> iterateV 5 (+1) 1
<1,2,3,4,5> :: Vector Integer
|
|
|
The function copyV generates a vector with a given number of copies of the same element.
Vector> copyV 7 5
<5,5,5,5,5,5,5> :: Vector Integer
|
|
Produced by Haddock version 2.1.0 |