Skip to content

Instantly share code, notes, and snippets.

View jooyunghan's full-sized avatar

Jooyung Han jooyunghan

View GitHub Profile
@tonymorris
tonymorris / PureIO.java
Last active December 18, 2017 02:30
Pure-functional terminal I/O in java
import java.util.function.Function;
import java.util.function.BiFunction;
import java.util.Scanner;
abstract class TerminalOperation<A> {
// this ensures that there are no subclasses of TerminalOperation
// outside of this class
private TerminalOperation() {
}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Prelude hiding (log)
--------------------------------------------------------------------------------
-- The API for cloud files.
class Monad m => MonadCloud m where
saveFile :: Path -> Bytes -> m ()
@flatmap13
flatmap13 / LookAndSay.scala
Created December 3, 2014 20:52
reactive look-and-say sequence w/ RxScala
import rx.lang.scala.Observable
import rx.lang.scala.subjects.BehaviorSubject
object LookAndSay {
def main(args: Array[String]) {
val pipe = BehaviorSubject(Observable.just('1'))
pipe.map(next).foreach(x => {
x.doOnCompleted(println()).foreach(print(_))
pipe.onNext(x)
@zlqhem
zlqhem / waterpouring.scala
Last active December 27, 2015 23:49
written by jooyunghan and me
object waterpouring {
type State = (Int, Int)
val initState = (0, 0)
val target = 6
val limit = (4, 9)
abstract class Action {
def apply(current:State):State
}