[Swift-devel] Re: folding/sequential-while/whatever and accessing data in files

Mihael Hategan hategan at mcs.anl.gov
Sun Sep 9 17:32:52 CDT 2007


On Sun, 2007-09-09 at 18:42 +0000, Ben Clifford wrote:
> 
> On Fri, 7 Sep 2007, Mihael Hategan wrote:
> 
> > On Fri, 2007-09-07 at 17:12 -0500, Mihael Hategan wrote:
> > > On Fri, 2007-09-07 at 22:04 +0000, Ben Clifford wrote:
> > > > 'v in a' doesn't get used at all... more complicated
> > 
> > Maybe this should be approached differently:
> > for k in a.keys {}
> > for v in a.values {}
> > for kv in a.entries {print(kv.key); print(kv.value);}
> 
> some shift like that could be nice for what I percieve as a problem with 
> this syntax:
> 
>  for v,i in a {
>   b[i] = f(v);
>  }

I thought it was i,v. Which probably shows exactly the problem.

> 
> Its more consistent to write { b[i] = f(a[i]) }

Yes; given the assumption that we always iterate on indexed things.

> 
> The .keys syntax above would support that.
> 




More information about the Swift-devel mailing list