This file contains 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
// assuming elements in a set do not repeat | |
let rec kCombinations k (set: 'a list) = | |
match k with | |
| 1 -> set |> List.map (fun x -> [x]) | |
| _ -> | |
match set with | |
| [] -> [] | |
| head::tail -> | |
(tail |> kCombinations (k - 1) |> List.map (fun x -> head::x)) | |
@ (tail |> kCombinations k) |
This file contains 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
/// A tic-tac-toe piece, or the absence thereof. | |
type Piece = U | X | O | |
/// Tic-tac-toe board position. | |
type Position = { X : int; Y : int } | |
[<AutoOpen>] | |
module GameModule = | |
/// A tic-tac-toe game implemented as a Pure ADT. |
This file contains 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 FSharpx.State | |
/// A tic-tac-toe piece, or the absence thereof. | |
type Piece = U | X | O | |
/// Tic-tac-toe board position. | |
type Position = { X : int; Y : int } | |
[<AutoOpen>] | |
module GameModule = |
This file contains 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
module Parsing | |
/// Remember where we are in the code. | |
/// This is a struct to keep memory pressure down. | |
/// (Significant perf improvements on iOS.) | |
type ParseState = | |
struct | |
val Code : string | |
val Index : int | |
new (code : string, index : int) = |
This file contains 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 | |
// helper function to set the console collor and automatically set it back when disposed | |
let consoleColor (fc : ConsoleColor) = | |
let current = Console.ForegroundColor | |
Console.ForegroundColor <- fc | |
{ new IDisposable with | |
member x.Dispose() = Console.ForegroundColor <- current } | |
// printf statements that allow user to specify output color |
This file contains 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
namespace Newtonsoft.Json.Converters | |
open Microsoft.FSharp.Reflection | |
open Newtonsoft.Json | |
open System | |
type IdiomaticDuConverter() = | |
inherit JsonConverter() | |
[<Literal>] |
This file contains 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
using Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Web; |
This file contains 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
namespace Marvel | |
open System | |
open System.Diagnostics | |
open System.Threading | |
open System.Threading.Tasks | |
open Marvel | |
/// The 'Vsync' (AKA, 'Variable Synchrony') monad. | |
/// Runs code synchronously when the 'Venom/System/Sync' Consul variable is 'True', in parallel otherwise. | |
/// NOTE: to reference how all this stuff works in F#, see here - https://msdn.microsoft.com/en-us/library/dd233182.aspx |
This file contains 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
module Tuple2 | |
let replicate x = x, x | |
let curry f x y = f (x, y) | |
let uncurry f (x, y) = f x y | |
let swap (x, y) = (y, x) |
This file contains 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
namespace MyNamespace | |
type IMyInterface = | |
abstract GetValue: unit -> string | |
type MyRecord = | |
{ MyField1: int | |
MyField2: string } | |
interface IMyInterface with | |
member x.GetValue() = x.MyField2 |
OlderNewer