Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33480
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2016-01-19 12:15 -0800 |
| References | <39a5793c-6a65-4402-9c11-69667a03f11d@googlegroups.com> <n7k3mr$6pq$1@dont-email.me> <a3a0221a-a5e6-4e0d-9018-4aa770e3eeb5@googlegroups.com> |
| Message-ID | <a9c0a5df-cfab-4bf0-90bb-c99d9573a72c@googlegroups.com> (permalink) |
| Subject | Re: Stream FlatMap |
| From | Philipp Kraus <philipp.kraus.flashpixx@gmail.com> |
> Yes, that's a variant of the Rosetta solution: There solution differs from yours by having List in the signature and the instanceof check inside the flatMap. I like that better, because the signature already announces that only Lists can be flattened.
Thanks for the code excerpt. I have modified this code:
public static Stream<Object> flattenToStream(List<?> list) {
return list.stream().flatMap(item ->
item instanceof List<?> ?
flattenToStream((List<?>)item) :
Stream.of(item));
}
for my system, so it works well with my term, atom structure :-)
Phil
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Stream FlatMap Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-01-18 07:57 -0800
Re: Stream FlatMap Sebastian <news@seyweiler.dyndns.org> - 2016-01-18 23:11 +0100
Re: Stream FlatMap Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-01-18 18:18 -0500
Re: Stream FlatMap Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-01-18 20:34 -0500
Re: Stream FlatMap Sebastian <sebastian.millies@softwareag.com> - 2016-01-19 04:12 -0800
Re: Stream FlatMap Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-01-19 12:15 -0800
Re: Stream FlatMap Arne Vajhøj <arne@vajhoej.dk> - 2016-01-21 10:12 -0500
csiph-web