Skip to content

Instantly share code, notes, and snippets.

View kciter's full-sized avatar
👀
Focusing

Sunhyoup Lee kciter

👀
Focusing
View GitHub Profile
@kciter
kciter / linked_list_fp.js
Last active August 16, 2021 03:41
함수형으로 작성한 단일 연결 리스트
const reduce = (f) => (acc, iter) => {
if (!iter) acc = (iter = acc[Symbol.iterator]()).next().value;
for (const a of iter) acc = f(acc, a);
return acc;
}
const go = (arg, ...fs) => reduce((arg, f) => f(arg))(arg, fs);
const Pair = (left, right) => (destructurePair) => destructurePair(left, right);
@kciter
kciter / Comprehension.kt
Created June 28, 2025 03:04
Kotlin Effect
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
@OptIn(ExperimentalContracts::class)
inline fun <V, E: Throwable> binding(crossinline block: BindingScope<E>.() -> V): Effect<V, E> {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}