Skip to content

Instantly share code, notes, and snippets.

@cmbrown1598
cmbrown1598 / Diamond.fsx
Created October 13, 2017 21:27
The Diamond Kata
open System
let diamond char =
let chars = [ 'A' .. char ]
let numberOfChars = List.length chars
let padCount i = numberOfChars - (i + 1)
let gridWidth = numberOfChars * 2 - 1
let pad i = new string (' ', i)
let init = chars |> List.mapi (fun i c -> (string c), (padCount i))
let all = init @ (List.tail (List.rev init))
type ShortCode = private ShortCode of string
type ProductShortCode = private ProductShortCode of ShortCode
type AccountShortCode = private AccountShortCode of ShortCode
module ShortCode =
let create s =
if System.String.IsNullOrEmpty s then None
elif s.Length > 15 then None
else Some (ShortCode s)
let vals = [(1000, "M");(900, "CM");(500, "D");(400, "CD");
(100, "C");(90, "XC");(50, "L");(40, "XL");
(10, "X");(9,"IX");(5,"V");(4,"IV");(1, "I")]
let toRoman iVal =
let rec loop acc n list =
match list with
| [] -> acc
| (i, s)::xs when n >= i -> loop (acc + s) (n - i) list
| x::xs -> loop acc n xs
open System
open System.Data
open System.Data.SqlClient
let bigGrossQuery = "SELECT c.id, c.accountName
FROM dbo.accounts AS c
WHERE c.accountName IN
( << A GIGANTIC LIST OF ACCOUNTS >> );"
let connectionString = "Server=myserver.redacted.org;