Skip to content

Instantly share code, notes, and snippets.

View takahisa's full-sized avatar

Takahisa Watanabe takahisa

  • Cybozu, Inc
  • Tokyo, Japan
View GitHub Profile
@takahisa
takahisa / syb1.hs
Last active January 17, 2017 00:25
Scrap_Your_Boilerplate_1
{-# LANGUAGE DeriveDataTypeable #-}
module Main where
import Data.Generics
import Data.Data
import Data.Typeable
data Exp = Add Exp Exp | Sub Exp Exp | Val Int
deriving (Show, Eq, Typeable, Data)
eval :: Exp -> Exp
hamming :: [Int]
hamming = filter p [1..]
where
p :: Int -> Bool
p x | x `mod` 5 == 0 = p (x `div` 5)
| x `mod` 3 == 0 = p (x `div` 3)
| x `mod` 2 == 0 = p (x `div` 2)
| otherwise = x == 1
main :: IO ()
let _8 = fun _9 -> _9 in
let rec _0 _1 _10 =
let _11 = fun _3 -> _10 _3 in
if _1 < 0 then
_11 0
else
_0 (_1 - 1) (fun _6 -> _11 (_1 + _6))
in (_0 10) (fun _2 -> _8 _2)
let quad_eq a b c =
let eq = b * b - 4 * a * c in
let ret = begin
if eq > 0 then
2
else if eq = 0 then
1
else
0
end in
var any = Chars.Any();
var newline = Combinator.Choice(Chars.Sequence("\u000d\u000a"),
Chars.Sequence("\u000d"),
Chars.Sequence("\u000a"))
.Ignore();
var lineCommentBegin = Chars.Sequence("//");
var lineComment = lineCommentBegin
.Right(Flows.Until(any, eof.Or(newline)))
.Ignore();
$PSVersionTable
Name Value
---- -----
CLRVersion 2.0.50727.5477
BuildVersion 6.1.7601.17514
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
Require Import List Arith.
Require Import Recdef.
Lemma lemma1:
forall (a : Type) (f : a -> bool) (n : a) (xs : list a),
length (filter f (n :: xs)) = if f n then 1 + length (filter f xs)
else length (filter f xs).
Proof.
intros a f n xs.
simpl.
#include <stdio.h>
#include <stdlib.h>
#define MAX(x, y) ((x == M) ? x : (y == M) ? y : (x > y) ? x : y)
#define MIN(x, y) ((x == M) ? y : (y == M) ? x : (x < y) ? x : y)
typedef int Weight;
#define M (-1)
#define N (6)
#include <stdio.h>
void swap(int* a, int* b) {
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
int euclid(int a, int b) {
#include <stdio.h>
int n;
int route[100][100];
int dtable[100];
int distance (int i, int j);
int main(void)