#ifINTERACTIVE#r@"..\..\packages\FSharp.Data\lib\net45\FSharp.Data.dll"#elsemoduleColours#endifopenFSharp.Data[<Literal>]letUrl_a_f="https://en.wikipedia.org/wiki/List_of_colors:_A%E2%80%93F"[<Literal>]letUrl_g_m="https://en.wikipedia.org/wiki/List_of_colors:_G%E2%80%93M"[<Literal>]letUrl_n_z="https://en.wikipedia.org/wiki/List_of_colors:_N%E2%80%93Z"type``ColoursA-F``=HtmlProvider<Url_a_f>letcolours_a_f=``ColoursA-F``.Load(Url_a_f).Tables.``ColorsinalphabeticalorderA-F``.Rows|>Seq.map(funr->r.Name,r.``Hex(RGB)``)type``ColoursG-M``=HtmlProvider<Url_g_m>letcolours_g_m=``ColoursG-M``.Load(Url_g_m).Tables.``ColorsinalphabeticalorderG-M``.Rows|>Seq.map(funr->r.Name,r.``Hex(RGB)``)type``ColoursN-Z``=HtmlProvider<Url_n_z>letcolours_n_z=``ColoursN-Z``.Load(Url_n_z).Tables.``ColorsinalphabeticalorderN-Z``.Rows|>Seq.map(funr->r.Name,r.``Hex(RGB)``)// Combine the threeletcolours=colours_n_z|>Seq.appendcolours_g_m|>Seq.appendcolours_a_f|>Seq.cacheletdistancehex1hex2=lethexToInts=System.Convert.ToInt32(s,16)// convert hex string to (R:int * G:int * B:int)// e.g. "#FFFFFF" to (255, 255, 255)letgetRGB(hex:string)=letr=hex.[1..2]|>hexToIntletg=hex.[3..4]|>hexToIntletb=hex.[5..6]|>hexToInt(r,g,b)let(r1,g1,b1)=getRGBhex1let(r2,g2,b2)=getRGBhex2(r1-r2)*(r1-r2)+(g1-g2)*(g1-g2)+(b1-b2)*(b1-b2)letmatchColourhex'=colours|>Seq.minBy(fun(_,hex)->distancehex'hex)colours|>Seq.length|>printfn"Total number of colours: %i""#FFFFF1"|>matchColour|>printfn"Best match for your colour: %A"