[Swift-devel] Problem with iterate

Mihael Hategan hategan at mcs.anl.gov
Sun Feb 21 14:33:16 CST 2010


On Sun, 2010-02-21 at 19:39 +0000, Ben Clifford wrote:
> > There's also the list comprehension way with C-like syntax, which
> > involves no array indices:
> 
> yeah, I had forgotten about that. It seems to keep the shape a bit better.
> 
> This is the same as your example (if I understand your example), in 
> Haskell:
> 
> a = do
>   p <- [1,2,3]
>   return $ do
>      q <- [10,20,30]
>      return (p + q)
> 
> main = print a
> 

mike at blabla tmp$ ./a.out
[[11,21,31],[12,22,32],[13,23,33]]

It seems to do the right thing.




More information about the Swift-devel mailing list