Skip to content

Instantly share code, notes, and snippets.

@zshamrock
Last active August 29, 2015 13:57
Show Gist options
  • Save zshamrock/9659104 to your computer and use it in GitHub Desktop.
Save zshamrock/9659104 to your computer and use it in GitHub Desktop.
range->drop->filter in Scala, Clojure and Java 8
(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