Usually I write this code after a couple of days of learning the language...so in no way I can be aware of all the crazy and optimized features...
This code is just for fun and for me...a really good way to introduce the syntax of a language in a very friendly way...
So...here's is Kotlin -:)
| LEDNumbers.kt |
|---|
package LEDNumbers
fun main(args: Array<String>) {
if (args.size == 0) {
println("Please provide a number...")
return
}
val NumList:List<String> = args[0].split("")
val Leds = mapOf("0" to listOf(" _ ", "| | ", "|_| "),
"1" to listOf(" ", "| ", "| "),
"2" to listOf(" _ "," _| ","|_ "),
"3" to listOf("_ ","_| ","_| "),
"4" to listOf(" ","|_| "," | "),
"5" to listOf(" _ ","|_ "," _| "),
"6" to listOf(" _ ","|_ ","|_| "),
"7" to listOf("_ "," | "," | "),
"8" to listOf(" _ ","|_| ","|_| "),
"9" to listOf(" _ ","|_| "," _| "))
for(i in 0..2){
for(j in 1..NumList.size - 2){
print(Leds[NumList[j]]!![i])
}
print("\n")
}
}
|
The result will like this -;)
Greetings,
Blag.
Development Culture.

No hay comentarios:
Publicar un comentario