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


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

Re: Puzzler: Fun with Streams.

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Puzzler: Fun with Streams.
Date Wed, 13 May 2015 08:21:35 -0400
Organization A noiseless patient Spider
Lines 31
Message-ID <mivfm2$hit$1@dont-email.me> (permalink)
References <Nfy4x.122164$566.49072@fx20.iad>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 13 May 2015 12:22:26 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="8e164d158183579609bf09837dee5210"; logging-data="18013"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+22mBMWOhAmwY508+1oo/eVtvsXa4hJ0c="
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0
In-Reply-To <Nfy4x.122164$566.49072@fx20.iad>
Cancel-Lock sha1:NPFqDl+qDIAaJQ0UcPi4umKC3+4=
Xref csiph.com comp.lang.java.programmer:31693

Show key headers only | View raw


On 05/12/2015 10:01 PM, Daniel Pitts wrote:
> It occurred to me that I could write this little snippet someplace, and
> it would work.
>
>      return stream.filter(o->o<-o);
>
> stream is an object which implements java.util.stream.BaseStream, though
> I won't tell you which one
>
> Might be obvious to everyone, but I thought it was a good little puzzler.
>
> What input do you think this will work with, and what is the result?

package example;

import java.util.Arrays;
import java.util.stream.IntStream;

public class FilterTest {

   public static void main(String[] args) {
     int[] test = new int[]{-2,-1,0,1,2};
     filter(test).forEach(p -> System.out.println(p));

   }
   static IntStream filter(int[] t) {
     IntStream stream = Arrays.stream(t);
     return stream.filter(o->o<-o);
   }

}

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


Thread

Puzzler: Fun with Streams. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2015-05-12 19:01 -0700
  Re: Puzzler: Fun with Streams. Jeff Higgins <jeff@invalid.invalid> - 2015-05-13 08:21 -0400
    Re: Puzzler: Fun with Streams. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2015-05-13 12:49 -0700
  Re: Puzzler: Fun with Streams. scattered <rescattered@gmail.com> - 2015-05-18 05:49 -0700
    Re: Puzzler: Fun with Streams. scattered <rescattered@gmail.com> - 2015-05-18 06:29 -0700
  Re: Puzzler: Fun with Streams. javadiscover@gmail.com - 2015-06-10 03:19 -0700

csiph-web