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 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.* |
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 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>() |
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.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 } | |
} |
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 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)) } |
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 operator | |
>>> def myop(optype, second): return lambda first: optype(first,second) | |
... | |
>>> myop(operator.lt,60)(45) | |
True | |
>>> myop(operator.lt,60)(80) | |
False |
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 time | |
import sys | |
def do_task(): | |
time.sleep(0.1) | |
def example_1(n): | |
steps = n/10 | |
for i in range(n): | |
do_task() | |
if i%steps == 0: |
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
3 | |
ejp mysljylc kd kxveddknmc re jsicpdrysi | |
rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd | |
de kr kd eoya kw aej tysr re ujdr lkgc jv |
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
# Copied from http://pastebin.com/Vg9Reb0Z to preserve from accidental deletion | |
# A library for manipulating polynomials in arbitrarily many | |
# indeterminates and of arbitrary degree. This library is 13 lines of | |
# code, excluding whitespace and comments. This isn't the smartest or | |
# most efficient way to do things, but I thought it was a cool way to | |
# demonstrate the power of itertools | |
# | |
# Monomials are pairs of a coefficient and a list of exponents; | |
# polynomials are lists of monomials. |
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 misc | |
import scala.math | |
object Prime { | |
def prime(num: Int) = | |
num > 1 && | |
(2 to (math.sqrt(num) toInt)).forall ( num % _ != 0) | |
def main(args: Array[String]): Unit = { | |
1 to 100 filter prime foreach println |
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
from functools import partial | |
mode = "debug" | |
def get_logger(stream = None) : | |
if stream is None : | |
return __builtins__.print | |
else : | |
return partial(__builtins__.print,file=stream) | |
def main() : |
NewerOlder