This file contains 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
{-# 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 |
This file contains 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
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 () |
This file contains 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
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) |
This file contains 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
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 |
This file contains 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
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(); |
This file contains 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
$PSVersionTable | |
Name Value | |
---- ----- | |
CLRVersion 2.0.50727.5477 | |
BuildVersion 6.1.7601.17514 | |
PSVersion 2.0 | |
WSManStackVersion 2.0 | |
PSCompatibleVersions {1.0, 2.0} |
This file contains 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
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. |
This file contains 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
#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) |
This file contains 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
#include <stdio.h> | |
void swap(int* a, int* b) { | |
int tmp; | |
tmp = *a; | |
*a = *b; | |
*b = tmp; | |
} | |
int euclid(int a, int b) { |
This file contains 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
#include <stdio.h> | |
int n; | |
int route[100][100]; | |
int dtable[100]; | |
int distance (int i, int j); | |
int main(void) |