Skip to content

Instantly share code, notes, and snippets.

View shhyou's full-sized avatar
💭
Alive

shuhung shhyou

💭
Alive
View GitHub Profile
global _start
[BITS 32]
_start:
mov ecx, 20000000
call _func
_func:
pop eax
sub esp, 4
dec ecx
jz .exit
global _start
[BITS 32]
_start:
mov ecx, 10000000
_loop:
call _func
loop _loop
finish:
xor eax,eax
xor ebx,ebx
global _start
[BITS 32]
_start:
xor eax,eax
call _func
mov ecx, 200
_loop:
mov eax, 100000
call _func
loop _loop
#!/usr/bin/python
repeat_num = 5
log_name = "~/eval-bench/log.txt"
bench_set = {
"automotive": {
"compile": ["for fil in `ls`; do pushd $fil; make; popd; done"],
"test": ["basicmath", "bitcount", "qsort", "susan"]
},
{-# LANGUAGE GADTs, TypeOperators, NoMonomorphismRestriction #-}
module AlgMonad where
-- for simplicity, we only use Int state
data Si m a where
Return :: Monad m => a -> Si m a
(:>>=) :: Monad m => Si m a -> (a -> Si m b) -> Si m b
Promote :: Monad m => m a -> Si m a
Get :: Monad m => Si m Int
{- The presentation here are mostly taken from Okasaki's book and
- joshkos's slide: http://www.cs.ox.ac.uk/people/hsiang-shang.ko/OAOAOO/FitA.pdf -}
module Binomial where
-- BinTree A ~= μT. 1 + A * [T]
data BinTree a = Bin a [BinTree a] -- store the sub-binomial trees from
deriving (Show) -- higher rank to lower rank
link :: Ord a => BinTree a -> BinTree a -> BinTree a

Case-expression 額外介紹

一堆範例

trivial

一個無用的資料型別,整個型別就只有一個值:TheOne

data NonTrivial = TheOne
\documentclass{article}
% Math Tpyings
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{colonequals}
\usepackage[margin=3cm]{geometry}
\usepackage{bussproofs}
\input{mathdef.tex}
@shhyou
shhyou / Shapes.hs
Last active August 29, 2015 14:03
Modified from Jeremy Gibbons' lecture, Functional Programming for Domain-Specific Language, FLOLAC 2014.
{-
Revision of Jeremy Gibbons' lecture material, Functional Programming for Domain-Specific Language, FLOLAC 2014.
http://www.cs.ox.ac.uk/publications/publication7583-abstract.html
http://flolac.iis.sinica.edu.tw/flolac14/doku.php?id=zh-tw:spl
(Removed the dependency on `diagrams`.
Note: You'll have to install blaze-svg and colour:P
#include <iostream>
/*
* class Eq a where
* (==) :: a -> a -> Bool
* (/=) :: a -> a -> Bool
*/
template<typename a>
struct Eq {
virtual bool equal(const a&, const a&) const = 0;