Skip to content

Instantly share code, notes, and snippets.

@jesseschalken
Created April 29, 2021 23:49
Show Gist options
  • Save jesseschalken/3a8c58004c2f88db0a828551de5e788e to your computer and use it in GitHub Desktop.
Save jesseschalken/3a8c58004c2f88db0a828551de5e788e to your computer and use it in GitHub Desktop.
Convert Booleans to a braille String in Kotlin Java Scala
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