Skip to content

Instantly share code, notes, and snippets.

View ezksd's full-sized avatar
🎯
Focusing

ezksd ezksd

🎯
Focusing
View GitHub Profile
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java -Didea.launcher.port=7534 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 14.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/javafx-doclet.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/htmlconverte
@ezksd
ezksd / EightQueens.java
Created January 21, 2017 07:09
eight queens in a line
package core;
import java.util.function.BiFunction;
import java.util.function.Function;
public class EightQueens {
static <A, B> A car(Pair<A, B> pair) {
return pair.a;
import java.util.function.Supplier;
public interface Lazy<T> extends Supplier<T> {
static <T> Lazy<T> of(Supplier<T> sup) {
return new LazyImpl<T>(sup);
}
static <T> Lazy<T> ofSafe(Supplier<T> sup) {
return new LazyThreadSafe<T>(sup);
import java.util.function.Supplier;
public interface Lazy<T> extends Supplier<T> {
static <T> Lazy<T> of(Supplier<T> sup) {
return new LazyImpl<T>(sup);
}
static <T> Lazy<T> ofSafe(Supplier<T> sup) {
return new LazyThreadSafe<T>(sup);
import java.util.function.Supplier;
public interface Lazy<T> extends Supplier<T> {
static <T> Lazy<T> of(Supplier<T> sup) {
return new LazyImpl<T>(sup);
}
static <T> Lazy<T> ofSafe(Supplier<T> sup) {
return new LazyThreadSafe<T>(sup);
@ezksd
ezksd / Lazy.java
Last active February 17, 2017 01:46
import java.util.function.Supplier;
public interface Lazy<T> extends Supplier<T> {
static <T> Lazy<T> of(Supplier<T> sup) {
return new LazyImpl<T>(sup);
}
static <T> Lazy<T> ofSafe(Supplier<T> sup) {
return new LazyThreadSafe<T>(sup);
import java.util.function.Function;
import java.util.function.Supplier;
interface TailRec<A> {
default <B> TailRec<B> map(Function<A, B> f) {
return flatmap(x -> new Call<>(() -> new Done<>(f.apply(x))));
}
default <B> TailRec<B> flatmap(Function<A, TailRec<B>> f) {
if (this instanceof Done) {
import java.util.function.Function;
import java.util.function.Supplier;
interface TailRec<A> {
default <B> TailRec<B> map(Function<A, B> f) {
return flatmap(x -> new Call<>(() -> new Done<>(f.apply(x))));
}
default <B> TailRec<B> flatmap(Function<A, TailRec<B>> f) {
if (this instanceof Done) {
@ezksd
ezksd / Interpreter.scala
Created March 11, 2017 09:05
interpreter
package ezksd
import ezksd.Parser.parse
object Interpreter {
type Continuation[T] = T => Unit
@inline
def cps_map(l: List[Any], f: (Any, Any => Unit) => Unit, k: Continuation[List[Any]]) {
module Parser where
import Control.Applicative
import Control.Monad
import Control.Monad.Trans.State
import Data.Char
type Parser a = StateT String Maybe a
runParse :: Parser a -> String -> Maybe a
runParse p s = do (a,b) <- runStateT p s