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 Random | |
(w,h) = (600, 400) | |
initialPosition = (0, 0) | |
intToDir d n = | |
if d < 0.5 | |
then n | |
else -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
import Random | |
(w,h) = (600, 400) | |
initialPosition = (0, 0) | |
step2 seed = | |
let floats = Random.floatList (always 4 <~ seed) | |
randCoords [f1,f2,f3,f4] = | |
let s = if f1 < 0.01 then 50 else 1 | |
n = if f2 < 0.5 then s else -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
import Generator as Gen | |
import Generator.Standard as Gs | |
(w,h) = (100,100) | |
-- Vectors | |
type Vec2 = { x : Float | |
, y : Float | |
} |
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
%% K - number of bits to represent `exp`, | |
%% N - number of bits to represent `frac`. | |
%% | s | exp(k bits) | frac(n bits) | | |
make_float_converter(K, N) -> | |
Bias = math:pow(2, K-1) - 1, | |
Max_denom = math:pow(2, N), | |
Max_exp = round(math:pow(2, K) - 1), | |
fun(<<S:1, Exp:K, Frac: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
#include <stdio.h> | |
#include <math.h> | |
void square_lu(float A[][3], float L[][3], float U[][3]) | |
{ | |
int n = 3; | |
for (int k = 0; k < n; k++) | |
{ | |
L[k][k] = 1.0f; | |
for (int i = k+1; i < n; i++) |
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 Pascal | |
export pascal | |
function factorial(n) | |
if n==0; return(1); end | |
result = n * factorial(n-1) | |
return(result) | |
end |
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
function tridiag_elem(i,j) | |
if abs(j-i) > 1; return(0); end | |
return(1); | |
end | |
function tridiag_mat(n) | |
[tridiag_elem(i,j) for i in [0:n-1], j in [0:n-1]] | |
end |
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
#lang racket | |
;; USAGE: | |
;; ===== | |
;; (init-hashtable 100) | |
;; (insert ht 13 3) | |
;; (lookup ht 13) | |
;; (delete ht 13) | |
;; list of random integers in [0, num-buckets); used for hashing |
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 "core_bench" | |
> open Core.Std;; | |
> open Core_bench.Std;; | |
let run_bench tests = | |
Command.run (Bench.make_command tests);; |
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
open Core.Std | |
type point = {x : float; | |
y : float} | |
let avg_two a b = | |
0.75 *. a +. 0.25 *. b | |
let avg_two_points a b = | |
{x= (avg_two a.x b.x); |
OlderNewer