Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #9954
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | "Nasser M. Abbasi" <nma@12000.org> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Java 8 Lambda binary snapshot |
| Date | Mon, 14 Nov 2011 08:03:46 -0600 |
| Organization | Aioe.org NNTP Server |
| Lines | 56 |
| Message-ID | <j9r744$4oq$1@speranza.aioe.org> (permalink) |
| References | <j9k23f$u03$1@dont-email.me> <2244638.2045.1321057203472.JavaMail.geo-discussion-forums@prep8> <0kuvb71v0ie3qtupn8d04q27fer5s0l49u@4ax.com> <4ec000d8$0$293$14726298@news.sunsite.dk> |
| Reply-To | nma@12000.org |
| NNTP-Posting-Host | r3dxhyOQqo8wOMSV7/0mbw.user.speranza.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9954 |
Show key headers only | View raw
On 11/13/2011 11:39 AM, Arne Vajhøj wrote:
> Java 8 lambda:
>
> import java.util.ArrayList;
> import java.util.Collections;
>
> public class Lambda {
> public static void main(String[] args) {
> ArrayList<String> lst = new ArrayList<String>();
> lst.add("A");
> lst.add("BB");
> lst.add("CCC");
> Collections.sort(lst, (s1,s2)-> -s1.compareTo(s2));
> for(String s : lst) {
> System.out.println(s);
> }
> }
> }
>
> Arne
>
ps. I just heard about this Lambda thing ;)
This looks like the ability to have, what is called in Mathematica,
or may be other functional languages, a pure function, that one
can define and use on the fly ?
For example, in Mathematica, one can write
"Sort[list,p]
sorts using the ordering function p. "
and is coded like this, for example:
In[11]:= Sort[{4,1,3,2,2},#1>#2&]
Out[11]= {4,3,2,2,1}
where the '&' indicates the end of the function, and
#1 means first argument, and #2 mean the second argument.
One can also write the pure function more explicit, like this:
In[8]:= Sort[{4,1,3,2,2},Function[{x,y},x<y]]
Out[8]= {1,2,2,3,4}
Is this, somewhat, close to what Lambda in Java allows?
It is very useful feature to be able to do this sort of thing.
(I need to read more about Java 8, sounds interesting)
--Nasser
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Java 8 Lambda binary snapshot markspace <-@.> - 2011-11-11 12:55 -0800
Re: Java 8 Lambda binary snapshot Lew <lewbloch@gmail.com> - 2011-11-11 16:20 -0800
Re: Java 8 Lambda binary snapshot markspace <-@.> - 2011-11-11 16:38 -0800
Re: Java 8 Lambda binary snapshot Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-11-12 06:36 -0400
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-12 09:19 -0500
Re: Java 8 Lambda binary snapshot Lew <lewbloch@gmail.com> - 2011-11-12 10:07 -0800
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-12 17:09 -0500
Re: Java 8 Lambda binary snapshot Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-11-14 06:25 -0400
Re: Java 8 Lambda binary snapshot Lew <lewbloch@gmail.com> - 2011-11-14 06:45 -0800
Re: Java 8 Lambda binary snapshot Robert Klemme <shortcutter@googlemail.com> - 2011-11-14 23:28 +0100
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-15 20:34 -0500
Re: Java 8 Lambda binary snapshot Lew <lewbloch@gmail.com> - 2011-11-15 22:28 -0800
Re: Java 8 Lambda binary snapshot BGB <cr88192@hotmail.com> - 2011-11-16 07:43 -0700
Re: Java 8 Lambda binary snapshot kensi <kensi_kensington@zoonoses.de> - 2011-11-16 12:53 -0500
Re: Java 8 Lambda binary snapshot "Nasser M. Abbasi" <nma@12000.org> - 2011-11-16 12:20 -0600
Re: Java 8 Lambda binary snapshot BGB <cr88192@hotmail.com> - 2011-11-16 14:27 -0700
Re: Java 8 Lambda binary snapshot Lew <lewbloch@gmail.com> - 2011-11-16 14:04 -0800
Re: Java 8 Lambda binary snapshot BGB <cr88192@hotmail.com> - 2011-11-17 10:05 -0700
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-16 18:57 -0500
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-12 09:23 -0500
Re: Java 8 Lambda binary snapshot Roedy Green <see_website@mindprod.com.invalid> - 2011-11-13 09:12 -0800
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-13 12:39 -0500
Re: Java 8 Lambda binary snapshot Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-11-13 20:13 +0000
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-13 15:43 -0500
Re: Java 8 Lambda binary snapshot Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-11-13 21:06 +0000
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-13 16:16 -0500
Re: Java 8 Lambda binary snapshot "Nasser M. Abbasi" <nma@12000.org> - 2011-11-14 08:03 -0600
Re: Java 8 Lambda binary snapshot Lew <lewbloch@gmail.com> - 2011-11-14 06:51 -0800
Re: Java 8 Lambda binary snapshot Roedy Green <see_website@mindprod.com.invalid> - 2011-11-12 04:53 -0800
Re: Java 8 Lambda binary snapshot markspace <-@.> - 2011-11-12 14:02 -0800
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-12 17:09 -0500
Re: Java 8 Lambda binary snapshot markspace <-@.> - 2011-11-12 19:14 -0800
Re: Java 8 Lambda binary snapshot BGB <cr88192@hotmail.com> - 2011-11-12 20:56 -0700
Re: Java 8 Lambda binary snapshot Lew <lewbloch@gmail.com> - 2011-11-13 05:08 -0800
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-13 10:08 -0500
Re: Java 8 Lambda binary snapshot markspace <-@.> - 2011-11-13 08:08 -0800
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-13 12:23 -0500
Re: Java 8 Lambda binary snapshot Roedy Green <see_website@mindprod.com.invalid> - 2011-11-13 09:23 -0800
Re: Java 8 Lambda binary snapshot Arne Vajhøj <arne@vajhoej.dk> - 2011-11-13 12:27 -0500
Re: Java 8 Lambda binary snapshot Lew <lewbloch@gmail.com> - 2011-11-13 11:08 -0800
csiph-web