Skip to content

Instantly share code, notes, and snippets.

@meganehouser
Created April 4, 2015 00:47
Show Gist options
  • Save meganehouser/457c0b149b8e866205e6 to your computer and use it in GitHub Desktop.
Save meganehouser/457c0b149b8e866205e6 to your computer and use it in GitHub Desktop.
Show LED numbers.
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