From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,cd3701d5ec722b08 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!j19g2000vbp.googlegroups.com!not-for-mail From: Martin Newsgroups: comp.lang.ada Subject: Re: Lambda expressions? LINQ? Date: Sat, 19 Sep 2009 09:38:26 -0700 (PDT) Organization: http://groups.google.com Message-ID: <415ed6b3-2a97-46da-95f0-179632c64b91@j19g2000vbp.googlegroups.com> References: <9b330aae-2c83-4d1c-995b-192425cd1c52@m11g2000vbl.googlegroups.com> <030adeb6-23c6-407e-8ac8-d0470fcbc3c0@o21g2000vbl.googlegroups.com> NNTP-Posting-Host: 86.154.213.155 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1253378306 18104 127.0.0.1 (19 Sep 2009 16:38:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 19 Sep 2009 16:38:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j19g2000vbp.googlegroups.com; posting-host=86.154.213.155; posting-account=g4n69woAAACHKbpceNrvOhHWViIbdQ9G User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.0.10, Ant.com Toolbar 1.3,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8397 Date: 2009-09-19T09:38:26-07:00 List-Id: On Sep 19, 3:35=A0pm, Brad Moore wrote: > Martin wrote: > > On Sep 19, 3:33 am, "Steve D" wrote: > > [snip] > >> As Martin guessed it is one statement spread over a few lines. > > >> =A0 =A0 =A0 =A0 =A0 =A0 string[] names =3D xDoc.Descendants("Layer0Mes= sage") > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .SelectMan= y(node =3D> > >> node.Attribute("To").Value.Split(' ',',').Where( st =3D> st.Length > 0= )) > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .D= istinct().OrderBy(n=3D>n).ToArray(); > > >> Oh, and by the way. =A0LINQ isn't just for XML. =A0You can do queries = on arrays, > > =A0>> lists, etc. =A0For example if you have an array of records you can = do a > =A0>> query to select all of the records with a field that has a particul= ar > =A0>> value. It's cool. > > >> I just wish my favoriate language had this feature. > > > Me too - although I can't see how it could be :-( > > I'm not sure I see why this couldn't be. > At first glance, the code fragment looks a lot like Ada. > > If existing packages (such as XML/Ada see > (http://libre.adacore.com/libre/tools/xmlada/) do not already > have this capability, then why couldn't someone write such a package in > Ada? I don't see the language being a barrier here. > Ada.Containers.Vectors for example lets you query an array of records to > select all the records with a field that has a particular value. > > What is missing? > > Brad Well, perhaps you could using the dot notation as above but the real value of LINQ to me is the sql like syntax that you can see in examples, such as those on the MS site, e.g. public void Linq11() { List products =3D GetProductList(); var productInfos =3D from p in products select new {p.ProductName, p.Category, Price =3D p.UnitPrice}; Console.WriteLine("Product Info:"); foreach (var productInfo in productInfos) { Console.WriteLine("{0} is in the category {1} and costs {2} per unit.", productInfo.ProductName, productInfo.Category, productInfo.Price); } } Check that 'select new {' line...very SQL! Even to my Ada-eyes a 'dot notation' version just isn't as readable. Cheers -- Martin