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 "stdafx.h" | |
#include <vector> | |
#include <stdio.h> | |
#include <atlcoll.h> | |
int _tmain(int argc, _TCHAR* argv[]) | |
{ | |
std::vector<int> data; | |
data.resize(10000000); | |
FILE *f = fopen("ints.dat", "rb"); |
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
void readAndMeasure(K)(size_t num, string fname) { | |
auto data = cast(K[]) std.file.read(fname); | |
enforce(data.length == num); | |
auto h = new RHHash!(K,int); | |
measure("# " ~ typeof(h).stringof ~ ".make_histo", (){ | |
foreach(x; data) | |
h[x]++; | |
}); | |
measure("# " ~ typeof(h).stringof ~ ".read_histo", (){ | |
int v = 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
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace mangolian | |
{ | |
struct Pair<A, B> | |
{ | |
public A fst; | |
public B snd; |
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
module main; | |
import std.stdio, std.range, std.algorithm, std.string, std.typecons; | |
enum W = 3; | |
enum H = 5; | |
char[W][H][10] symbols = [["111", "101", "101", "101", "111"], ["110", "010", "010", "010", "111"], | |
["111", "001", "111", "100", "111"], ["111", "001", "111", "001", "111"], ["101", "101", "111", "001", "001"], | |
["111", "100", "111", "001", "111"], ["111", "100", "111", "101", "111"], ["111", "001", "011", "010", "010"], | |
["111", "101", "111", "101", "111"], ["111", "101", "111", "001", "111"]]; |
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
line: 1 col: 1 digit: 0 | |
line: 1 col: 5 digit: 1 | |
line: 1 col: 9 digit: 2 | |
line: 1 col: 13 digit: 3 | |
line: 1 col: 17 digit: 4 | |
line: 1 col: 21 digit: 5 | |
line: 1 col: 25 digit: 6 | |
line: 1 col: 29 digit: 7 | |
line: 1 col: 33 digit: 8 | |
line: 1 col: 37 digit: 9 |
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
module main; | |
import std.stdio, std.range, std.algorithm, std.string, std.typecons; | |
enum W = 3; | |
enum H = 5; | |
char[W][H][10] symbols = [["111", "101", "101", "101", "111"], ["110", "010", "010", "010", "111"], | |
["111", "001", "111", "100", "111"], ["111", "001", "111", "001", "111"], ["101", "101", "111", "001", "001"], | |
["111", "100", "111", "001", "111"], ["111", "100", "111", "101", "111"], ["111", "001", "011", "010", "010"], | |
["111", "101", "111", "101", "111"], ["111", "101", "111", "001", "111"]]; |
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
import Data.List | |
import Control.Monad.ST | |
import Control.Monad | |
import Data.Array.ST | |
import Data.Array.Unboxed | |
data Exp = IfGt Int Int Block Block -- if a[i] > a[j] then blk1 else blk2 | |
| Swap Int Int -- a[i] <-> a[j] (i,j < 8) | |
| Copy Int Int -- a[i] <- a[j] (i > 7) | |
deriving Show |
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
type exp = IfGt of int * int * block * block | |
| Swap of int * int | |
| Copy of int * int | |
and block = exp list;; | |
let rec eval a = function | |
| IfGt(i, j, b1, b2) -> | |
let (r,n) = evalBlock a (if a.(i) > a.(j) then b1 else b2) in | |
(r, n+1) | |
| Swap(i, j) -> |
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
import std.stdio, std.algorithm; | |
struct Exp { | |
enum Tag { IfGt, Swap, Copy } | |
Tag tag; | |
int i, j; | |
Exp[] bl1, bl2; | |
} | |
int eval(int[] a, const ref Exp e) { |
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
type exp = IfGt of int * int * block * block | |
| Swap of int * int | |
| Copy of int * int | |
and block = exp list;; | |
let rec eval a = function | |
| IfGt(i, j, b1, b2) -> | |
1 + evalBlock a (if a.(i) > a.(j) then b1 else b2) | |
| Swap(i, j) -> | |
let ai = a.(i) and aj = a.(j) in |
OlderNewer