This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec genPairs list = | |
match list with | |
| [] -> [] | |
| x::ys -> [for y in ys -> x, y] @ genPairs ys | |
let items = ["joe"; "jim"; "jack"; "jud"] | |
let r = new System.Random() | |
let shuffle cards = cards |> List.map (fun card -> r.Next(),card) |> List.sort |> List.map snd | |
items |> shuffle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec pairs list = | |
match list with | |
| [] -> [] | |
| x::ys -> [for y in ys -> x, y] @ pairs ys | |
pairs [1..4] | |
let rec pairslc list = [ | |
match list with | |
| [] -> () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mono: Config attempting to parse: '/Library/Frameworks/Mono.framework/Versions/4.4.0/etc/mono/config'. | |
Mono: Config attempting to parse: '/Users/jwostenberg/.mono/config'. | |
Mono: _wapi_handle_new: Creating new handle of type Event | |
Mono: _wapi_handle_new: Allocated new handle 0x400 | |
Mono: process_set_name: using [/Applications/Pipeline.app/Contents/MonoBundle/Pipeline.exe] as prog name | |
Mono: _wapi_handle_new: Creating new handle of type Process | |
Mono: _wapi_handle_new: Allocated new handle 0x401 | |
Mono: Assembly Loader probing location: '/Library/Frameworks/Mono.framework/Versions/4.4.0/lib/mono/4.5/mscorlib.dll'. | |
Mono: Image addref mscorlib[0x78682140] -> /Library/Frameworks/Mono.framework/Versions/4.4.0/lib/mono/4.5/mscorlib.dll[0x79071c00]: 2 | |
Mono: Assembly Loader probing location: '/Library/Frameworks/Mono.framework/Versions/4.4.0/lib/mono/4.5/mscorlib.dll'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open Microsoft.FSharp.Reflection | |
type Suit = | Clubs | Spades | Hearts | Diamonds | |
type Rank = | |
| Two | Three | Four | Five | |
| Six | Seven | Eight | Nine | Ten | |
| Jack | Queen | King | Ace | |
type Card = { rank: Rank // Rank field must come before suit so that card comparison is correct | |
suit: Suit } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
type State<'s, 'a> = State of ('s -> ('a * 's)) | |
module State = | |
let inline run state x = let (State(f)) = x in f state | |
let get = State(fun s -> s, s) | |
let put newState = State(fun _ -> (), newState) | |
let map f s = State(fun (state: 's) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
module String = | |
let split chars (s: string) = s.Split chars | |
/// Lazily returns every file and directory that has the given root path as a parent. Directories paths | |
/// occur before their children. | |
let rec getSystemEntriesRec path = | |
seq { yield path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Cell = | On | Off | |
let (%) x m = ((x % m) + m) % m | |
/// Tells you how many neighbors are on | |
let nOnNeighbors (cells : _ [,]) (x, y) = | |
[for xOffset in -1..1 do | |
for yOffset in -1..1 do | |
if not ((xOffset = 0) && (yOffset = 0)) then | |
let x = (x + xOffset) % Array2D.length1 cells |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Endo = EndsWith of string*string| NoEnding of string | |
EndsWith ("a","b") | |
NoEnding "a" | |
let breakEndingO (w:string) ending = if w.EndsWith ending then w.[0..w.Length-ending.Length-1],ending else w,"" | |
let breakEnding (w:string) ending = if w.EndsWith ending then EndsWith (w.[0..w.Length-ending.Length-1],ending) else NoEnding(w) | |
breakEnding "hellooByInch" "ByInch" | |
breakEnding "xInch" "Inch" | |
breakEnding "Inch" "Inch" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 44 bytes! | |
let rec s n=seq{yield!string n;yield!s(n+1)} | |
// Usage | |
s 0 |> Seq.nth 100 | |
s 0 |> Seq.nth 10000000 |