jbanana: Badly drawn banana (Default)
[personal profile] jbanana
I was trying to get my head round Java 8 streams. Here's a typical example:
List<Integer> transactionsIds = transactions.stream()
         .filter(t -> t.getType() == Transaction.GROCERY)
         .sorted(comparing(Transaction::getValue).reversed())
         .map(Transaction::getId)
         .collect(toList());
"Get the grocery transactions, largest value first, and tell me their IDs."

So this seems cool, and you can make a stream parallel, so it might be a good way to implement a lot of things.

The lightbulb came on when I realised that you can only apply a predefined set of operations. The thing you're calling methods on is the stream, not the contents. So you might be able to re-write existing code in terms of filter, map, etc. but you can't just drop an existing chunk of code into a stream and get magic.
From:
Anonymous (will be screened)
OpenID (will be screened if not validated)
Identity URL: 
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org


 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

July 2017

M T W T F S S
     12
3456789
10111213141516
17 181920212223
24 252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 26th, 2017 04:29 am
Powered by Dreamwidth Studios