Skip to content

Instantly share code, notes, and snippets.

@akimboyko
Created July 30, 2013 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akimboyko/6110425 to your computer and use it in GitHub Desktop.
Save akimboyko/6110425 to your computer and use it in GitHub Desktop.
JavaScript-like immediate function in F#, am I losing sanity?
let magicSquare = (fun () ->
let randomSequence =
(seq { 1 .. N * N })
|> Seq.sortBy(fun n -> random.Next())
|> Seq.toArray
Matrix.Generic.init N N
(fun nRow nColumn -> randomSequence.[nRow * N + nColumn]))()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment