This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
;; (def related-posts | |
;; ^{:doc "Returns n posts related to `post`."} | |
;; (memoize | |
;; (fn [in-dir post n] | |
;; (->> (:tags post) | |
;; (map #(get (tag-buckets (all-pages in-dir)) %)) | |
;; (apply concat) | |
;; (map #(dissoc % :file :tags)) | |
;; (remove #{post}) | |
;; (frequencies) |
This file contains hidden or 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
(defn max-key-val | |
[f & args] | |
(reduce (fn [[max f-of-max] i] | |
(let [f-of-i (f i)] | |
(if (> f-of-i f-ofmax) | |
[i f-of-i] | |
[max f-of-max]))) | |
[(first args) (f (first args))] | |
(rest args))) |
This file contains hidden or 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
(defn max-key-val | |
"Like max-key, but returns [x (f x)] for which (f x) is greatest" | |
[f & args] | |
(let [z (zipmap args (map f args))] | |
(reduce (fn [max i] | |
(if (> (second i) (second max)) | |
i | |
max)) | |
(first z) | |
(rest z)))) |
This file contains hidden or 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
(defn new-file-name [file] | |
(let [metadata (metadata file) | |
slug (or nil (:slug metadata)) | |
parsed-date (or (or (parse (:date metadata)) nil) | |
(local-now))] | |
(if slug (-> (clojure.string/replace slug #"\/" "-") | |
(clojure.string/replace #"-blog-" "")) | |
(str | |
(year parsed-date) "-" | |
(if (= (count (str (month parsed-date))) 2) |