Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1 @@
scala -e "for(y<-0 to 15){println(\" \"*(15-y)++(0 to y).map(x=>if((~y&x)>0)\" \"else\" *\")mkString)}"

View file

@ -0,0 +1,10 @@
def sierpinski(n: Int) {
def star(n: Long) = if ((n & 1L) == 1L) "*" else " "
def stars(n: Long): String = if (n == 0L) "" else star(n) + " " + stars(n >> 1)
def spaces(n: Int) = " " * n
((1 << n) - 1 to 0 by -1).foldLeft(1L) {
case (bitmap, remainingLines) =>
println(spaces(remainingLines) + stars(bitmap))
(bitmap << 1) ^ bitmap
}
}

View file

@ -0,0 +1,12 @@
def printSierpinski(n: Int) {
def sierpinski(n: Int): List[String] = {
lazy val down = sierpinski(n - 1)
lazy val space = " " * (1 << (n - 1))
n match {
case 0 => List("*")
case _ => (down map (space + _ + space)) :::
(down map (List.fill(2)(_) mkString " "))
}
}
sierpinski(n) foreach println
}