Skip to content

Instantly share code, notes, and snippets.

View gist:c367566c8f6e905620791b41c1ec74d4
let rotateList amount initialList =
let rec rotate amount myList =
if amount = 0
then myList |> List.rev
else
let newestList =
match myList |> List.rev with
| h::rest ->
let newList = (rest@[h]) |> List.rev
View FsxBundle.fsx
open System
open System.IO
type Line = string
type Load = string
type Lines = Line list
type Loads = Load list
type Code = Lines
type FsxPath = string
@monkieboy
monkieboy / vscodeAndPaket.sh
Created Jan 31, 2017
Shell script F# functions to add to .bashrc on *nix systems
View vscodeAndPaket.sh
code () {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
open -a "Visual Studio Code" --args "$F"
fi
}
View sentiment.fs
open System
open System.IO
open edu.stanford.nlp.ling
open edu.stanford.nlp.neural.rnn
open edu.stanford.nlp.sentiment
open edu.stanford.nlp.trees
open edu.stanford.nlp.util
open java.util
open edu.stanford.nlp.pipeline
View BatteryLifeProgram.fs
module ProgNet.Program
open System
open ProgNet.ClimbHill
[<EntryPoint>]
let main argv =
let printTitle title =
printfn ""
View FsCheckShuffle.fs
open FsCheck
let newDeck =
[ for r in [1..14] do
yield ("C",r)
yield ("H",r)
yield ("D",r)
yield ("S",r) ]
let genFullShuffledDeck =
gen
View HandGen.fs
let genHand : Gen<Hand> =
let deck =
gen {
let! seed = Gen.choose (0, 100000)
let deck = shuffle newDeck seed
return deck }
gen {
let! (ShuffledDeck d) = deck
let hand =
View Time.fsx
let time countN label f =
let stopwatch = System.Diagnostics.Stopwatch()
System.GC.Collect()
printfn "Started"
let getGcStats() =
let gen0 = System.GC.CollectionCount(0)
let gen1 = System.GC.CollectionCount(1)
let gen2 = System.GC.CollectionCount(2)
@monkieboy
monkieboy / films.fsx
Last active Dec 23, 2015
Top 100 Grossing Films (as of 23 December 2015) unsorted
View films.fsx
let films :list<string*int64> =
[ ("Inside Out", 851458049L)
("Star Wars Episode III: Revenge of the Sith", 848754768L)
("Spectre", 837191062L)
("Transformers: Revenge of the Fallen", 836303693L)
("The Twilight Saga: Breaking Dawn – Part 2", 829746820L)
("Inception", 825532764L)
("Spider-Man", 821708551L)
("Independence Day", 817400891L)
("The Hobbit: An Unexpected Journey", 1021103568L)
@monkieboy
monkieboy / range.fsx
Created Nov 17, 2015
Playing with ranges
View range.fsx
let (..) (start:int) (limit:int) =
let sequence = [start..limit]
let decapitate h t =
if t = List.empty
then [ h ]
else t |> List.rev
let reversed =
match sequence with