Skip to content

Instantly share code, notes, and snippets.

@lyricallogical
lyricallogical / FizzBuzz.hs
Created October 10, 2011 15:04 — forked from konn/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
@lyricallogical
lyricallogical / daigakusei.v
Created February 26, 2012 04:40 — forked from erutuf/daigakusei.v
ボクには ; 使ったのは気持ちはなんとなくわかるけど imihu だったので一つずつ証明した。
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,
$ 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 / Macros.scala
Last active December 13, 2015 23:39 — forked from xuwei-k/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
}
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)
}