Snippets created by Tony Lee

  • Gaussian Random Sequence

    Normalized Random sequence generator conforming to the user supplied mean and sigma utilizing a "seed factory" instead of the default time of day. The Gaussian sequence is based on the central limit theory, averages together the flat distribution from the random generator built into .NET. Two examples of using normalRand are given to create infinite sequences of white and brown(ian) noise.

    45 people like this

    Posted: 13 years ago by Tony Lee

  • exec with redirected io as sequences

    Since F# is my new scripting language, I needed something like Perl's exec but with sequences for Std In and Out.

    7 people like this

    Posted: 13 years ago by Tony Lee

  • SHA256

    Calculates sha256 of the files passed in on the command line. Usage: fsi sha256.fsx downloadedFile.zip

    2 people like this

    Posted: 13 years ago by Tony Lee

  • Restartable File.ReadLines

    .Net 4.0 added File.ReadLines to view a file as a sequence, but the sequence can only be read once. A simple wrapper with seq{yield!} fixes that.

    44 people like this

    Posted: 13 years ago by Tony Lee

  • Incremental (Functional) QuickSort

    Functional quicksort inspired by the Haskell Quick Sort at http://www.haskell.org/haskellwiki/Introduction. Since F# lists aren't lazy, uses sequences instead of lists to be haskell like. Roughly O(n) if you Seq.take 1, full on QS if you enumerate the whole thing.

    3 people like this

    Posted: 13 years ago by Tony Lee

  • Bigint range sequence

    An F# bigint range is slow (see SOQ: http://stackoverflow.com/q/20534191). This an IENum built specifically for bigint that has reasonable speed. ~4 seconds instead of nearly 20 on my old mac mini

    1 people like this

    Posted: 10 years ago by Tony Lee