Skip to content

Instantly share code, notes, and snippets.

//A collection of small Java 8 related utility methods, just for the fun of it.
public class Java8Tricks {
public static <T> Stream<T> stream(Iterator<? extends T> iterator) {
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false);
}
public static <A, B> Iterator<Entry<A, B>> zip(Iterator<? extends A> s1, Iterator<? extends B> s2) {
return Iterators.transform(s1, e1 -> immutableEntry(e1, s2.next()));
@sergio-castro
sergio-castro / LogtalkLoader.java
Last active November 24, 2018 00:50
This class shows an easy way to configure Logtalk in SWI or YAP using the Jpl library, together with examples of simple invocations of Logtalk methods from Java. You need to have the jpl jar in your classpath to compile and execute this file.
import jpl.Atom;
import jpl.Compound;
import jpl.JPL;
import jpl.Query;
import jpl.Term;
/**
* This class shows how to configure Logtalk in SWI or YAP using the Jpl library.
* You need to have the jpl jar in your classpath to compile and execute this file.