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,5 @@
import lists.zip
def
pascal( 1 ) = [1]
pascal( n ) = [1] + map( (a, b) -> a + b, zip(pascal(n-1), pascal(n-1).tail()) ) + [1]

View file

@ -0,0 +1,3 @@
import integers.choose
def pascal( n ) = [choose( n - 1, k ) | k <- 0..n-1]

View file

@ -0,0 +1,11 @@
def triangle( height ) =
width = max( map(a -> a.toString().length(), pascal(height)) )
if 2|width
width++
for n <- 1..height
print( ' '*((width + 1)\2)*(height - n) )
println( map(a -> format('%' + width + 'd ', a), pascal(n)).mkString() )
triangle( 10 )