Created
April 4, 2015 00:47
-
-
Save meganehouser/457c0b149b8e866205e6 to your computer and use it in GitHub Desktop.
Show LED numbers.
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 | |
let ledNums = [ | |
[" _ "; "| |"; "|_|"] | |
[" "; " |"; " |"] | |
[" _ "; " _|"; "|_ "] | |
[" _ "; " _|"; " _|"] | |
[" "; "|_|"; " |"] | |
[" _ "; "|_ "; " _|"] | |
[" _ "; " _|"; "|_|"] | |
[" _ "; " |"; " |"] | |
[" _ "; "|_|"; "|_|"] | |
[" _ "; "|_|"; " |"]] | |
let parse c = | |
let result, num = Int32.TryParse(c.ToString()) | |
match result with | |
| true -> Some(num) | |
| false -> None | |
while true do | |
Console.Write("input number: ") | |
let nums = Console.ReadLine() | |
|> Seq.choose(parse) | |
[0..2] | |
|> List.fold(fun acc i -> | |
let line = nums |> Seq.fold(fun l n -> l + ledNums.[n].[i]) "" | |
acc + line + Environment.NewLine | |
) "" | |
|> printfn "%s" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment