Created
February 7, 2015 22:55
-
-
Save bjartwolf/ecb5371df0452cf0d851 to your computer and use it in GitHub Desktop.
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 R2 n = | |
let xs = [-n .. n] | |
seq { for x in xs do for y in xs do yield x,y } | |
let TaxicabNorm (x, y) = abs x + abs y | |
let radius = 10 | |
let indexedLetters = | |
['A' .. 'Z'] |> Seq.mapi (fun i l -> i,l) | |
let findLetter xcord = | |
let i,l = Seq.find(fun (i, l) -> i = abs xcord) indexedLetters | |
l | |
let diamond = (R2 radius) | |
|> Seq.filter (fun x -> TaxicabNorm x = radius) | |
|> Seq.map( fun (x, y) -> (x,y),findLetter x) | |
let whiteLines n = | |
let xs = [|-n .. n|] | |
[| for i in -n .. n -> (Array.map (fun _ -> '.') xs) |] | |
let drawing = whiteLines radius | |
for point in diamond do | |
let (x,y), letter = point | |
let yindex = Array.findIndex (fun elem -> y = elem) [|-radius .. radius|] | |
let xindex = Array.findIndex (fun elem -> x = elem) [|-radius .. radius|] | |
drawing.[xindex].[yindex] <- letter | |
let printArray (arr: char array) = new string (arr) |> sprintf "%A" |> Dump | |
for line in drawing do | |
printArray line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment