Fork me on GitHub
#uncomplicate
<
2017-04-07
>
blueberry17:04:58

@mroerni fmap! also accepts a (primitive) function whose first argument is a long -> that'll be the index of an element of a vector (column or row). Unfortunately, there is no way to provide both i and j... If you absolutely need both i and j, use (entry i j) in a loop...

blueberry17:04:15

@mroerni another option is to call fmap over all cols or rows.

blueberry17:04:09

@mroerni and the third option is to see whether you need those indexes at all, or there is some linear algebra function that can do what you need.

blueberry18:04:27

@mroerni just checked this. the previous is how fold works. fmap doesn't give the function access to the indexes. You'll have to loop yourself and use (entry! i j val).

blueberry18:04:23

@mroerni I think I have solution to what you want to do. 0.10.0-SNAPSHOT will have additional alter method variant that will alter all elements using a function, and feed indexes to this function if applicable. Watch the github repo and it will be there in a couple of days, since it is not difficult to implement.