Created
April 29, 2021 23:49
-
-
Save jesseschalken/3a8c58004c2f88db0a828551de5e788e to your computer and use it in GitHub Desktop.
Convert Booleans to a braille String in Kotlin Java Scala
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
fun Iterable<Boolean>.toBrailleString(): String = | |
chunked(8) { | |
fun p(i: Int, j: Int) = | |
if (i < it.size && it[i]) 1 shl j else 0 | |
'\u2800' + | |
p(0, 0) + p(1, 1) + p(2, 2) + p(3, 6) + | |
p(4, 3) + p(5, 4) + p(6, 5) + p(7, 7) | |
}.toCharArray().concatToString() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment