Skip to main content

Home/ Haskell/ Group items matching "Array" in title, tags, annotations or url

Group items matching
in title, tags, annotations or url

Sort By: Relevance | Date Filter: All | Bookmarks | Topics Simple Middle
Javier Neira

The Haskell 98 Library Report: Arrays - 0 views

  • 16.2  Incremental Array Updates The operator (//) takes an Array and a list of pairs and returns an Array identical to the left argument except that it has been updated by the associations in the right argument. (As with the Array function, the indices in the association list must be unique for the updated elements to be defined.) For example, if m is a 1-origin, n by n matrix, then m//[((i,i), 0) | i <- [1..n]] is the same matrix, except with the diagonal zeroed.
  • -- A rectangular subarray subarray :: (Ix a) => (a,a) -> array a b -> array a b subarray bnds = ixmap bnds (\i->i) -- A row of a matrix row :: (Ix a, Ix b) => a -> array (a,b) c -> array b c row i x = ixmap (l',u') (\j->(i,j)) x where ((_,l'),(_,u')) = bounds x -- Diagonal of a matrix (assumed to be square) diag :: (Ix a) => array (a,a) b -> array a b diag x = ixmap (l,u) (\i->(i,i)) x        where           ((l,_),(u,_)) = bounds x -- Projection of first components of an array of pairs firstarray :: (Ix a) => array a (b,c) -> array a b firstarray = fmap (\(x,y)->x)
1 - 4 of 4
Showing 20 items per page