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 interviewDS; | |
/** | |
* @author EmilyPillmore | |
* | |
* Naive base indexed implementation of the SkipList data structure | |
* Average Worst case | |
* Space O(n) O(n log n) | |
* Search O(log n) O(n) | |
* Insert O(log n) O(n) |
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 functionaljava.Data; | |
import functionaljava.Data.List; | |
import java.util.function.*; | |
abstract interface Either<A, B> { | |
abstract <T> T foldEither(final Function<? super A, ? extends T> f, Function<? super B,? extends T> g); | |
abstract List<Either<A, B>> lefts(List<Either<A, B>> xs); |
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
trait Instantiator[+A] { | |
def apply(): A | |
} | |
object Instantiator { | |
def apply[A](create: => A): Instantiator[A] = new Instantiator[A] { | |
def apply(): A = create | |
} | |
} |
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.language.higherKinds | |
import scala.util.{Try, Success} | |
import scala.annotation.tailrec | |
object Kinds extends App { | |
trait Functor[F[_]] { |
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 scala.annotation.tailrec | |
/** | |
* Created by emilypi on 5/17/17. | |
*/ | |
trait Stream[+A] { | |
import Stream._ | |
def head: () => A |
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 com.emilypi.scalaupnorth.fold | |
/** | |
* Created by emilypi on 5/18/17. | |
*/ | |
case class Mu[F[_]](unFix: F[Mu[F]]) |
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 cohomolo.gy.generalized | |
import scalaz.Prelude.{<~<, IsCovariant} | |
import scalaz.data.{As, Identity, ~>, ∀} | |
//final case class Mu[F[_]](unMu: Algebra[F, ?] ~> Identity) | |
trait MuModule { | |
type Mu[F[_]] |
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
trait CodensityModule { | |
type Codensity[M[_], A] | |
def abs[M[_], A](c: Codensity[M, A])(implicit M: Monad[M]): M[A] | |
def rep[M[_], A](ma: M[A])(implicit M: Monad[M]): Codensity[M, A] | |
} | |
private[data] object CodensityImpl extends CodensityModule with CodensityInstances { |
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
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
module Codensity where | |
newtype Codensity m a = Codensity { runCodensity :: forall b. (a -> m b) -> m b } | |
abs :: Monad m => (a -> m b) -> Codensity m a -> m b | |
abs k (Codensity c) = c k |
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
sealed abstract class FFree[F[_], A] { | |
def map[B](f: A => B): FFree[F, B] = | |
flatMap[B](a => FFree.pure[F, B](f(a))) | |
def flatMap[B](k: A => FFree[F, B]): FFree[F, B] = | |
this match { | |
case FFree.Pure(a) => k(a) | |
case FFree.Impure(ff, rs) => FFree.impure(ff, rs.:+(Kleisli.wrapKleisli(k))) | |
} |
OlderNewer