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) | |
} |
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 |
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, |
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 |