Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #33473

Re: Stream FlatMap

From Sebastian <news@seyweiler.dyndns.org>
Newsgroups comp.lang.java.programmer
Subject Re: Stream FlatMap
Date 2016-01-18 23:11 +0100
Organization albasani.net
Message-ID <n7jnv4$peu$1@news.albasani.net> (permalink)
References <39a5793c-6a65-4402-9c11-69667a03f11d@googlegroups.com> <flatten-20160118182917@ram.dialup.fu-berlin.de>

Show all headers | View raw


Am 18.01.2016 18:29, schrieb Stefan Ram:
> Philipp Kraus <philipp.kraus.flashpixx@gmail.com> writes:
>> List<?> x = [1,2, [4,5, ["a", "b"], "c", "d"], ["x", "y"], "z"];
>> and I would like to flat this list into
>
>    The verb is »to flatten«.
>
>    The code does not compile:
>
> Main.java:38: error: illegal start of expression
>      List<?> x = [1,2, [4,5, ["a", "b"], "c", "d"], ["x", "y"], "z"];
>                  ^
> 1 error
>

Well, obviously the OP didn't intend that as a list literal, since Java 
does not have them, but as shorthand in pseudo-code.

There's a solution at
http://rosettacode.org/wiki/Flatten_a_list#Java

It's ugly, does anyone see a way to avoid using instanceof?

-- Sebastian

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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