Skip to content

Instantly share code, notes, and snippets.

View loveqoo's full-sized avatar
🏠
Working from home

loveqoo loveqoo

🏠
Working from home
  • Incheon in South of Korea
View GitHub Profile
@tusharmath
tusharmath / trampoline.ts
Last active March 31, 2023 01:05
Trampolining in Typescript
// stub for typescript
declare function BigInt(n: number): number
abstract class Trampoline<A> {
abstract map<B>(ab: (a: A) => B): Trampoline<B>
abstract flatMap<B>(ab: (a: A) => Trampoline<B>): Trampoline<B>
zip<B>(tb: Trampoline<B>): Trampoline<[A, B]> {
const ta = this
return ta.flatMap(a => tb.map(b => [a, b] as [A, B]))
@takahirom
takahirom / EventBus.kt
Last active June 9, 2022 10:21
EventBus by Kotlin coroutine
import kotlinx.coroutines.experimental.channels.BroadcastChannel
import kotlinx.coroutines.experimental.channels.ConflatedBroadcastChannel
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.channels.filter
import kotlinx.coroutines.experimental.channels.map
import kotlinx.coroutines.experimental.launch
import javax.inject.Inject
import javax.inject.Singleton