Skip to content

Instantly share code, notes, and snippets.

View Vilkina's full-sized avatar
❤️
I may be slow to respond.

Aleksandra A Vilkina

❤️
I may be slow to respond.
View GitHub Profile
def copyChunk(from: AsynchronousFileChannel,
to : AsynchronousFileChannel) =
for {
chunk <- from.read(1024, 0)
_ <- to.write(chunk, 0)
} yield ()
// Array#update
val array = Array("a", "b", "c")
array.update(0, "z")
package com.oleksandrah.cakes
import com.oleksandrah.cakes.model.{Cake, Cakes, Tables}
import org.scalatra.ScalatraServlet
import org.scalatra.scalate.ScalateSupport
import slick.jdbc.H2Profile
import slick.jdbc.H2Profile.api._
import zio.{Exit, IO, Task, ZIO, _}
package ziolist.http4s
import org.http4s._
import zio._
import zio.interop.catz._
import org.http4s.server.blaze.BlazeServerBuilder
object Service {
//E for Effect
package ziolist
import zio.{ ZEnv, ZIO }
import zio._
sealed trait MyList[+ A] {
def head: Option[A]
def tail: MyList[A]
def isEmpty: Boolean
def add[B >: A](element: B): MyList[B]
def zipAllWith[@specialized B, @specialized C](that: Chunk[B])(left: A => C, right: B => C)(both: (A, B) => C): Chunk[C] = {
val size = self.length.max(that.length)
val minln = self.length.min(that.length)
if (size == 0 && minln == 0) Chunk.empty
else {
var j = 0
val c = both(self(j), that(j))
implicit val C: ClassTag[C] = Chunk.Tags.fromValue(c)

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x