Skip to content

Instantly share code, notes, and snippets.

@ImaginaryDevelopment
ImaginaryDevelopment / Catan.fsx
Created August 9, 2015 02:57
Catan modeling
//catan
// github.com/MichaelLPerry/dof
type Hand = { Wood: byte; Wheat: byte; Sheep: byte; Stone: byte; Gold:byte} with
member x.Values = [x.Wood; x.Wheat; x.Sheep; x.Stone; x.Gold]
member x.IsValid = x.Values |> Seq.forall ((>=) 0uy)
member x.HasAtLeast (resources:Hand) =
let calculated = x.Values |> Seq.map2 (<=) resources.Values
calculated |> Seq.forall id
static member Zero = {Wood = 0uy; Wheat = 0uy; Sheep = 0uy; Stone = 0uy; Gold = 0uy}
@ImaginaryDevelopment
ImaginaryDevelopment / maybe_without_objects.js
Last active December 21, 2015 21:39 — forked from timcharper/maybe_without_objects.js
maybe_without_objects adjusted for prototype calls and what not, in action at http://jsfiddle.net/Maslow/w8Uzw/
function type(obj) {
var obj_type = typeof obj;
return ({
is: function (type) {
return obj_type === type;
},
is_object: function () {
return obj_type === "object";
},
is_func: function () {