Last active
August 29, 2015 13:57
-
-
Save zshamrock/9659104 to your computer and use it in GitHub Desktop.
range->drop->filter in Scala, Clojure and Java 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(0 until 12).drop(4).filter(_ % 2 == 0) | |
(->> (range 12) (drop 4) (filter #(= (mod % 2) 0))) | |
LongStream.range(0, 12).skip(4).filter((n) -> (n % 2) == 0) | |
// of course for the Java the whole story is: | |
import java.util.Arrays; | |
import java.util.stream.LongStream; | |
public class Functional { | |
public static void main(String[] args) { | |
System.out.println(Arrays.toString( | |
LongStream.range(0, 12).skip(4).filter((n) -> (n % 2) == 0) | |
.toArray())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment