Write language name in 3D ASCII: Difference between revisions

m (added C output)
Line 1,778:
===Idiomatic===
Cleaner code.
<lang scala>objectimport Ascii3D extends App {scala.collection.mutable.ArraySeq
 
object Ascii3D extends App {
def ASCII3D = {
val nameArraypicture = """ *
** ** * * *
* * * * * * *
Line 1,793 ⟶ 1,795:
var arr = {
val (x, y) = // Get maximal format and create a 2-D array with it.
(nameArraypicture.foldLeft(0)((i, s) => i max s.length), nameArraypicture.size)
ArrayArraySeq.fill(y + 1, (x * 3) + (y + 1))(' ')
}
 
Line 1,800 ⟶ 1,802:
// Map asterisks to 3D cube
//
val (cubeTop, cubeBottom) = ("""///\""", """\\\/""") // "
 
for {
y <- 0 until nameArraypicture.size
x <- 0 until nameArraypicture(y).size
if nameArraypicture(y)(x) == '*'
indent = nameArraypicture.size - y
} {
arr(y) = arr(y) patch ((x * 3 + indent), cubeTop, cubeTop.size)
Anonymous user