This file contains hidden or 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
lambda = Lpr + 6.288750 * sin(Mpr) | |
+ 1.274018 * sin(2*D - Mpr) | |
+ 0.658309 * sin(2*D) | |
+ 0.213616 * sin(2*Mpr) | |
- e * 0.185596 * sin(M) | |
- 0.114336 * sin(2*F) | |
+ 0.058793 * sin(2*D - 2*Mpr) | |
+ e * 0.057212 * sin(2*D - M - Mpr) | |
+ 0.053320 * sin(2*D + Mpr) | |
+ e * 0.045874 * sin(2*D - M) |
This file contains hidden or 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
object Ishi extends App { | |
class Primes { | |
val primes: Stream[Long] = 2 #:: primesStartingFrom(3) | |
def isPrime(n: Long): Boolean = { | |
val limit = math.sqrt(n).ceil.toInt | |
!primes.takeWhile(_ < limit).exists(n % _ == 0) | |
} |
This file contains hidden or 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 T[A] | |
trait Bar[A] { | |
implicit def T: T[A] | |
} | |
trait Foo[A] extends Bar[A] | |
class Cake[A: T](a: A) extends Foo[A] { | |
def T: T[A] = implicitly |
This file contains hidden or 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
public class MyJavaClass { | |
protected int bar = 1; | |
} | |
trait MyScalaTrait extends MyJavaClass { | |
def foo = { | |
bar = bar + 1 | |
bar | |
} |
This file contains hidden or 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 language.higherKinds | |
object FooExample extends App { | |
// Slice of comonad is where this came up | |
trait Foo[F[_]] { | |
def coflatMap[A, B](f: F[A] => B): F[A] => F[B] | |
} | |
// A non-empty list |
This file contains hidden or 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
object stuff { | |
import scala.util.parsing.combinator._ | |
class Parser extends RegexParsers { | |
def parseTop(s: String): Stuff = parse(top(""), s) match { | |
case Success(value, _) => value | |
case _ => throw new RuntimeException("...") | |
} |
This file contains hidden or 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
implicit def mv[F] = new Monad[({ type λ[a] = Validation[F, a] })#λ] { | |
def bind[A, B](fa: Validation[F, A])(f: A => Validation[F, B]): Validation[F, B] = fa.flatMap(f) | |
def point[A](a: => A): Validation[F, A] = a.success | |
} |
This file contains hidden or 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
object Nafg { | |
object Tuples { | |
trait HT[A] { | |
type H | |
type T | |
def hd(a: A): H | |
def tl(a: A): T | |
} |
This file contains hidden or 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
object Tuples { | |
trait HT { | |
type H | |
type T | |
def hd: H | |
def tl: T | |
} | |
implicit class T3[A, B, C](t: (A, B, C)) extends HT { |
This file contains hidden or 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 annotation.implicitNotFound | |
@implicitNotFound(msg = "This message can never appear!") | |
trait ~>[A, B] { self => | |
def apply(a: A): B | |
def invert(b: B): A = inverse.apply(b) | |
def inverse: B ~> A = new ~>[B, A] { | |
def apply(b: B) = self.invert(b) | |
override def invert(a: A) = self(a) | |
} |