Skip to content

Instantly share code, notes, and snippets.

Nicolas Francois Koisell

Block or report user

Report or block Koisell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View functor1.scala
def map(fa: Foo[A])(f: A => B): Foo[B] = ???
View explicitRecursion.scala
// A function which calls itself explicitly:
def length[A](list: List[A]) = list match {
case h::t => 1 + length(t)
case Nil => 0
}
View list.scala
// A type which holds a reference to itself:
sealed abstract class List[+A]
final case class Cons[+A](head: A, tail: List[A]) extends List[A]
final case object Nil extends List[Nothing]
@Koisell
Koisell / foldl.scala
Last active Sep 23, 2019
Medium recursion schemes
View foldl.scala
List(1, 2, 3).foldl(0)(_ + _)
// foldl removes the explicit recursion.
// FOLD, REDUCE, ... already are recursion scheme
You can’t perform that action at this time.