Skip to content

Instantly share code, notes, and snippets.

@jarekratajski
jarekratajski / crt.kt
Last active August 25, 2020 12:55
Kotlin coroutines - where I doubt
//This is from hobby project which partially is based on
https://play.kotlinlang.org/hands-on/Building%20Web%20Applications%20with%20React%20and%20Kotlin%20JS/01_Introduction
//hobby project is https://github.com/neeffect/kotlin-stones (it is in fact playground - nothing serious)
// I had classic get operation from rest (in kotlinjs)
//original method
suspend fun fetchStones(): List<Stone> = coroutineScope {
window.fetch("/api/stones")
.await()
fibbtcoinner 0 sum presum = sum
fibbtcoinner n sum presum = fibbtcoinner (n-1) (sum + presum) sum
fibbtco n = fibbtcoinner n 1 0
fibbnaive 0 = 1
fibbnaive 1 = 1
fibbnaive n = fibbnaive ( n-1) + fibbnaive ( n - 2)
main = do
fibbtcoinner 0 sum presum = sum
fibbtcoinner n sum presum = fibbtcoinner (n-1) (sum + presum) sum
fibbtco n = fibbtcoinner n 1 0
fibbnaive 0 = 1
fibbnaive 1 = 1
fibbnaive n = fibbnaive ( n-1) + fibbnaive ( n - 2)
main = do
package pl.rm
import akka.actor.ActorSystem
import akka.stream.scaladsl.{GraphDSL, RunnableGraph, Source, ZipWithN}
import akka.stream.{ActorMaterializer, ClosedShape}
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
object AveragePrice {