Skip to content

Instantly share code, notes, and snippets.

@jcbozonier
Created December 3, 2008 05:28
Show Gist options
  • Select an option

  • Save jcbozonier/31422 to your computer and use it in GitHub Desktop.

Select an option

Save jcbozonier/31422 to your computer and use it in GitHub Desktop.
#light
open Microsoft.FSharp.Math
// instead try these categories
// Exciting/Serene; Uplifting/Depressing; Fun/Boring; Deep/Shallow; Technically Sound/Buggy; Worth More/Worth Less
let FableII = [3.; 3.; 3.; 0.; 3.; 0.]
let FarCryII = [0.; 0.; -1.; 1.; 5.; 0.]
let DeadSpace = [2.; -2.; 2.; 3.; 3.; 1.]
let JustinExpectations = [5.; 3.; 5.; -2.; 5.; 5.]
let SanityCheck = [-5.; -5.; -5.; -5.; -5.; -5.]
let magnitude a = System.Math.Sqrt(Seq.map (fun x->System.Math.Pow(x,2.)) a |> Seq.sum)
let dot a b = Seq.map2 (fun n m->n*m) a b |> Seq.sum
let arccos a = System.Math.Acos a
let percentage (value, compared_to) = 100. - value / compared_to * 100.
let similar x y = percentage (arccos((dot x y)/((magnitude x) * (magnitude y))), System.Math.PI)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment