Thanks Tim! I can always count on you to have solutions for everything :) On Mon, Jun 27, 2016 at 11:31 AM, Tim Holy <[email protected]> wrote:
> In Base there's mapslices, which may already do what you want. > > Something like what you're proposing (but not yet with a nice "high level" > API > wrapper, since the low-level stuff is still in flux) is already here: > https://github.com/timholy/ArrayIteration.jl > That's aiming at a very general approach that should be efficient for a > wide > variety of AbstractArrays (dense, sparse, perhaps even distributed, etc). I > bet you don't need so much generality? > > Assuming you'd be happy with something that works well for just dense > matrices, your `view(mat, :, i)` idea should work just fine. Given that > julia-0.5 is just around the corner, my assumption is that it would be > best to > put it in a package first, and think about adding to Base later. (But I'm > not > opposed to sticking it in now, either.) > > Best, > --Tim > > On Monday, June 27, 2016 9:42:33 AM CDT Tom Breloff wrote: > > I find myself frequently wanting to do something like: > > > > mat = rand(100,4) > > for c in columns(mat) > > # c is a vector (a view maybe?) > > end > > > > I think ideally this method would return a lazy iterator which returns a > > `view(mat, :, i)` at each step. Does this exist already? If not, would > it > > be welcomed in Base? > > > > -Tom > > >
