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
(** Run: | |
coretop existential.ml | |
*) | |
open Core.Std | |
type ('a, 'b) entity = { | |
id : unit -> string; | |
step : 'b -> 'b some_entity; | |
to_string : unit -> string; |
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
(** Run: | |
corebuild -pkg core_bench mat_mult.native && sleep 1 && ./mat_mult.native | |
*) | |
open Core.Std | |
open Core_bench.Std | |
module Array_mat = struct | |
type mat3 = float array array | |
type vec3 = float array |
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
run: fib | |
./fib | |
fib: fib.ml | |
ocamlfind ocamlopt nums.cmxa fib.ml -o fib |
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
all: var_len_arrays.c | |
gcc -O1 var_len_arrays.c -S |
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
all: pingcat.c | |
gcc -o pingcat pingcat.c |
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 <string.h> | |
#include <stdlib.h> | |
#define MAXN 5000000 | |
int n; | |
char c[MAXN], *a[MAXN]; | |
int pstrcmp(const void **x, const void **y) { |
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 sys | |
def bigmul(a, b): | |
"""r = a * b | |
where | |
r = bidmul(a, b)""" | |
xs = list(reversed(digits(a))) | |
ys = list(reversed(digits(b))) | |
zs = [0 for i in xrange(300)] | |
for i in xrange(len(ys)): |
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
main :: IO () | |
main = do | |
x <- getLine | |
y <- getLine | |
print (read x + read y) |
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
ultraDiv ∷ Integer → Integer → (Integer, Integer) | |
-- pre: 1 <= d <= n | |
-- post: a*d + b == n | |
-- && (A) x > d . (a*x > n) | |
-- where | |
-- (a, b) = ultraDiv n d | |
ultraDiv n d = bDiv n d 1 n | |
where | |
-- pre: same as ultraDiv | |
-- && d * lower <= n && d * upper > n |
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
-- PRE: xs is sorted and not null | |
-- POST: r is xs without the elements that vary by | |
-- more than err from the median | |
gausselim ∷ (Num a, Ord a) ⇒ a → [a] → [a] | |
gausselim err xs = filter good xs | |
where | |
middle = xs ‼ (length xs `div` 2) | |
good x = abs (x - middle) < err |
OlderNewer