This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="./mvvm.ts" /> | |
namespace Fowler { | |
export function mvvm( | |
ids: Dict<string> & { stations: string }, | |
dataSet: Reading[] | |
): Promise<never> { | |
return connect( | |
appOf(dataSet), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference lib="es2015" /> | |
type Visitor<R, V> = { | |
[K in keyof V]: V[K] extends any[] | |
? (...pattern: V[K]) => R | |
: never; | |
}; | |
type Sum<V> = <R>(visitor: Visitor<R, V>) => R; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (hex->dec str) | |
(>> (string-fold add-next 0 str) | |
:where ; deferred declaration of local bindings | |
(char-values (map cons (string->list "0123456789abcdef") (iota 16))) | |
#((add-next digit acc) ; lambda binding shorthand in :where clause | |
(>> (assv-ref char-values digit) | |
(or (error "invalid hex digit" digit str)) | |
(+ (* 16 acc)))))) | |
(define (dec->hex num) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Sum<K> = <T> (cases: Pattern<K, T>) => T; | |
type Pattern<K, T> = { | |
[C in keyof K]?: K[C] extends any[] ? (...args: K[C]) => T : never; | |
} & { | |
otherwise?: () => T | |
} | |
type List<T> = Sum<{nil: [], cons: [T, List<T>]}>; | |
function fallback<T>(): T { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package em.zed.literallynothing | |
import android.os.Bundle | |
import android.support.v7.app.AppCompatActivity | |
import android.support.v7.widget.LinearLayoutManager | |
import android.support.v7.widget.RecyclerView | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import android.widget.ProgressBar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.stream.StreamSupport; | |
public class LongDistance { | |
public static void main(String[] args) throws IOException { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
static class Retained { | |
final LipsumAdapter adapter = new LipsumAdapter(); | |
State loadState = State.Case::unknown; | |
} | |
interface State { | |
void match(Case of); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.function.Function; | |
public interface Adt { | |
static void main(String[] args) { | |
map(OptionOf.some(100), String::valueOf).match(new Option<String>() { | |
@Override | |
public void none() { | |
System.out.println("NONE!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.coroutines.experimental.* | |
fun main(vararg args: String) { | |
safeDiv(None(), Some(1)).let(::println) | |
safeDiv(Some(5L), Some(0.5)).let(::println) | |
safeDiv(Some(1), None()).let(::println) | |
for (x in 20..30 step 5) { | |
for (y in 15 downTo 0 step 5) { | |
print("$x / $y = ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package m; | |
import java.util.function.*; | |
public class Monads { | |
static <T, U> Function<Option<T>, Option<U>> | |
lift(Function<T, U> t2u) { | |
return ot -> pu -> ot.map(t2u).match(pu); | |
} |
NewerOlder