Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dnene on github.
  • I am dnene (https://keybase.io/dnene) on keybase.
  • I have a public key whose fingerprint is CB17 55C8 224B C815 1551 4E8A BF8F 0B76 0C72 85BB

To claim this, I am signing this object:

@dnene
dnene / ApplFuncMonads.kt
Last active April 8, 2018 08:36
Applicatives, Functors and Monads using Kotlin and Arrow
import arrow.core.*
import arrow.data.k
import arrow.syntax.applicative.tupled
import arrow.syntax.functor.map
import arrow.typeclasses.binding
typealias IntFunction = (Int) -> Int
fun IntFunction.map(g: IntFunction) = { it: Int -> this(g(it)) }
@dnene
dnene / timesequence.kt
Created July 24, 2018 13:48
Time Sequence vs No Sequencce
import kotlin.system.measureTimeMillis
fun main(args: Array<String>) {
val iterations = 10000000
val time1 = measureTimeMillis {
(1..iterations).forEach {
val result: List<Int> = (1..100).filter { it % 2 == 0 }.filter { it % 3 == 0 }.filter { it % 5 == 0 }
}
package tech.dnene.trials2
import arrow.core.*
typealias Error = String
// Strategy A - sealed classes - Requires support for OO/inheritance
sealed class Abstract<A>
data class Value(val i: Int): Abstract<Int>()
@dnene
dnene / passenger_cab_simulation.kt
Last active October 22, 2021 11:04
This simulates passenger and cab traffic at the pickup point at the airport
package tech.dnene.trials4.airporttaxi
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.produce
import org.slf4j.LoggerFactory
import java.time.Duration
import java.time.LocalDateTime
import java.util.*