Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 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