I've always learned that Java 8 streams are lazy. As such, I would expect that:
Optional<Integer> intOpt = Stream
.of(1, 2, 3)
.flatMap(i -> Stream.of(4, 5, 6))
.filter(i -> {System.out.println(i); return true;})
.findAny();
I've always learned that Java 8 streams are lazy. As such, I would expect that:
Optional<Integer> intOpt = Stream
.of(1, 2, 3)
.flatMap(i -> Stream.of(4, 5, 6))
.filter(i -> {System.out.println(i); return true;})
.findAny();
Create an empty project with SBT:
sbt new sbt/scala-seed.g8
Update build.sbt to contain the Metaborg repository:
import Dependencies._| task C { | |
| doLast { | |
| println("Do C") | |
| } | |
| } | |
| task A(dependsOn: C) { | |
| doLast { | |
| println("Do A") | |
| } |
| martijn@dhcp-10-175-42-124:/p/t/javatest$ cat Main.java | |
| import sun.misc.Unsafe; | |
| import java.lang.reflect.Field; | |
| public class Main { | |
| public static void main(String[] args) throws Exception { | |
| Unsafe unsafe = getUnsafe(); | |
| System.out.println("Page size = " + unsafe.pageSize()); | |
| } |
| plugins { | |
| id 'java' | |
| } | |
| repositories { | |
| jcenter() | |
| } | |
| dependencies { | |
| compileOnly 'com.google.code.findbugs:jsr305:3.0.2' |
| package nl.martijndwars.oshell; | |
| public class Foo { | |
| public static void main(String[] args) throws InterruptedException { | |
| Thread thread = new Thread(new Bar()); | |
| thread.start(); | |
| Thread.sleep(3000); | |
| thread.stop(); | |
| } |
| /* | |
| * Depend on Spoofax and replace org.graalvm:graal-sdk by org.graalvm.skd:graal-sdk. The exclusion | |
| * resolves a conflict during compilatin and also shows up in the generated .pom. | |
| */ | |
| plugins { | |
| id 'java' | |
| id 'maven-publish' | |
| } | |
| group = 'nl.martijndwars' |
| import scala.io.Source | |
| import scala.collection.mutable.Map | |
| object Asm { | |
| def main(args: Array[String]): Unit = { | |
| val lines = Source.fromFile("input.txt").getLines.toList | |
| val map = Map.empty[String, Int] | |
| // First, map all addresses to integers | |
| lines.filter(_.startsWith("0x")).map(_.take(18)).zipWithIndex.foreach { |