Skip to content

Instantly share code, notes, and snippets.

View queue.scala
import scala.annotation.tailrec
import scala.language.higherKinds
sealed trait Freer[F[_], A] {
def map[B](f: A => B): Freer[F, B] = flatMap(a => Pure(f(a)))
def flatMap[B](f: A => Freer[F, B]): Freer[F, B] =
this match {
case Pure(a) => f(a)
case Impure(fa, g) => Impure(fa, g :+ f)
}
@lyricallogical
lyricallogical / Macros.scala
Last active Dec 13, 2015 — forked from xuwei-k/Macros.scala
試してないけどこれでいいのでは
View Macros.scala
import scala.reflect.macros.Context
import scala.util.matching.Regex
import java.util.regex.PatternSyntaxException
object Macros{
implicit class RegexContext(val c: StringContext) {
def r(): Regex = macro regexImpl
}
View result.txt
$ scala rpnparser.scala
1 1 + = 2
3 1 - = -2
3 2 * = 6
8 2 / = 0
2 (2 2 +) + = 6
2 2 2 + + = 6
(2 2 +) 2 + = 6
(2 2 +) (4 2 +) * = 24
((2 2 +) (4 2 +) *) 2 / = 0
@lyricallogical
lyricallogical / daigakusei.v
Created Feb 26, 2012 — forked from erutuf/daigakusei.v
ボクには ; 使ったのは気持ちはなんとなくわかるけど imihu だったので一つずつ証明した。
View daigakusei.v
Inductive even : nat -> Prop :=
| even_O : even 0
| even_S : forall n, odd n -> even (S n)
with odd : nat -> Prop :=
| odd_S : forall n, even n -> odd (S n).
Scheme even_mut := Induction for even Sort Prop
with odd_mut := Induction for odd Sort Prop.
Theorem daigakuseinosuugakuryoku : forall n m,
@lyricallogical
lyricallogical / FizzBuzz.hs
Created Oct 10, 2011 — forked from konn/FizzBuzz.hs
コンパイル通るか知りません こんな感じのほうが人間に優しいのでは…!
View FizzBuzz.hs
fizzbuzz = zipWith max (map show [0..]) fb
where
fb = zipWith (++) f b
f = cycle ["Fizz", "", ""]
b = cycle ["Buzz", "", "", "", ""]
main = mapM_ putStrLn $ tail $ fizzBuzz
You can’t perform that action at this time.