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
(* Database provides key-generation and table-instantiation, | |
* so that a key can be associated to various properties. | |
*) | |
(* This is for a fully-controlled specification... | |
* | |
* module Db = Database.Make (Database.IntKey) | |
* module Prop = Db.MultiInherit | |
* module PropHash = Prop.Table(Database.Hash) | |
* module Size = (val PropHash.create ~default:0 () : Db.Sig with type t = int) |
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
(* "Magical Forest: Goats, Wolves, and Lions" | |
* | |
* Inspired by this reddit post: | |
* http://www.reddit.com/r/programming/comments/27e7r3/performance_comparison_of_java_8_c_11_and_the/ | |
* | |
* The following code can be pasted into an OCaml REPL. | |
* Then a solution is called for like this: | |
* | |
* magical_forest (683, 1054, 1290);; | |
* |
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
/* Some hash functions to generate pseudo-random values per-coordinate. | |
* Useful for spatial synthesis, such as procedural textures. | |
*/ | |
/*** Bob Jenkins' mix and final ***/ | |
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) | |
#define mix(a,b,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
(* | |
A few monads... the incentive was to have an easy way to work with Tsdl. | |
The "Result" monad corresponds to the result type returned by most Tsdl calls. | |
"Release" accumulates a chain of "clean-up" functions. | |
Together they form "Resource" which handles Ok/Error results and accumulates | |
clean-up functions which are returned. |
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
(* __ Interface-layer atop Tsdl.Sdl.Event _______________ | |
* | |
* | |
* Rationale for not using Tsdl directly for events: | |
* | |
* -Tsdl events are too raw -- easily able to read incorrect fields without | |
* generating a compile-time error. | |
* | |
* -Tsdl events are cumbersome to use: "Sdl.Event.(get e long_field_name)", | |
* and event container "e" must be in scope. |
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
(* Translated from Rust version at https://github.com/frol/completely-unscientific-benchmarks *) | |
type nodecell = node option | |
and node = | |
{ x: int; | |
y: int; | |
mutable left: nodecell; | |
mutable right: nodecell } | |
module Node = struct |