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,15 @@
\ print the array
: .arr \ a -- a
( . space ) a:each ;
: pasc \ a --
\ print the row
.arr cr
dup
\ create two rows from the first, one with a leading the other with a trailing 0
[0] 0 a:insert swap 0 a:push
\ add the arrays together to make the new one
' n:+ a:op ;
\ print the first 16 rows:
[1] ' pasc 16 times

View file

@ -0,0 +1,21 @@
: ratio \ m n -- num denom
tuck n:- n:1+ swap ;
\ one item in the row: n m
: pascitem \ n m -- n
r@ swap
ratio
n:*/ n:round int
dup . space ;
\ One row of Pascal's triangle
: pascline \ n --
>r 1 int dup . space
' pascitem
1 r@ loop rdrop drop cr ;
\ Calculate the first 'n' rows of Pascal's triangle:
: pasc \ n
' pascline 0 rot loop cr ;
15 pasc