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


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

Re: Puzzler: Fun with Streams.

From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Puzzler: Fun with Streams.
Date 2015-05-13 08:21 -0400
Organization A noiseless patient Spider
Message-ID <mivfm2$hit$1@dont-email.me> (permalink)
References <Nfy4x.122164$566.49072@fx20.iad>

Show all headers | 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