Well, if you want the first syntax you can easily define Base.enumerate(f::Function, args...) = map(t->f(t...), enumerate(args...))
You could always open a pull request if you wanted to see this in Base, too. On Thursday, 15 May 2014 21:18:31 UTC+1, Cameron McBride wrote: > > I missed enumerate() for a while, and was happy I found it. I find it > amusing how satisfying a few missing keystrokes can be. > > On a related but different note, from a similar influence, I keep wanting > to pass blocks to iterators. Any chance that will ever happen? > > I realize that do..end blocks are used currently as syntactic sugar for > methods that take a function as the first arg (e.g. open(), map()), and the > same functionality can be achieved with three letters and two braces (map), > but it still seems somewhat cleaner to write: > > enumerate(a) do i,x > ... > end > > over > > map(enumerate(a)) do i,x > ... > end > > which are really just equivalent, as we know, to > > for i,x, in enumerate(a) > ... > end > > Are there technical reasons this is a bad idea to assume? > > Cameron > > On Thu, May 15, 2014 at 1:01 PM, John Myles White > <[email protected]<javascript:> > > wrote: > >> I kind of suspect Stefan, like me, would instinctively call this >> operation `each_with_index`. >> >> -- John >> >> On May 15, 2014, at 6:33 AM, Kevin Squire <[email protected]<javascript:>> >> wrote: >> >> One nice thing about Julia is that she borrows many (though not all) good >> ideas from other languages. In this case, enumerate came from Python >> (although it likely has other incarnations). >> >> Cheers! >> Kevin >> >> On Thursday, May 15, 2014, Billou Bielour <[email protected]<javascript:>> >> wrote: >> >>> I was thinking the same thing the other day, when using *for x in xs* I >>> often find myself needing an index at some point and then I have to change >>> the for loop, or write an index manually. >>> >>> Enumerate is exactly what I need in this case. >>> >>> +1 for Julia >>> >>> >> >
