Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
[sx1q]sz[d0=zd1-lfx*]sf[skdlfxrlk-lfxlklfx*/]sb
|
||||
|
|
@ -0,0 +1 @@
|
|||
5 3lbxp
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
[ macro z: factorial base case when n is (z)ero ]sx
|
||||
[sx [ x is our dump register; get rid of extraneous copy of n we no longer need]sx
|
||||
1 [ return value is 1 ]sx
|
||||
q] [ abort processing of calling macro ]sx
|
||||
sz
|
||||
|
||||
[ macro f: factorial ]sx [
|
||||
d [ duplicate the input (n) ]sx
|
||||
0 =z [ if n is zero, call z, which stops here and returns 1 ]sx
|
||||
d [ otherwise, duplicate n again ]sx
|
||||
1 - [ subtract 1 ]sx
|
||||
lfx [ take the factorial ]sx
|
||||
* [ we have (n-1)!; multiply it by the copy of n to get n! ]sx
|
||||
] sf
|
||||
|
||||
[ macro b(n,k): binomial function (n choose k).
|
||||
straightforward RPN version of formula.]sx [
|
||||
sk [ remember k. stack: n ]sx
|
||||
d [ duplicate: n n ]sx
|
||||
lfx [ call factorial: n n! ]sx
|
||||
r [ swap: n! n ]sx
|
||||
lk [ load k: n! n k ]sx
|
||||
- [ subtract: n! n-k ]sx
|
||||
lfx [ call factorial: n! (n-k)! ]sx
|
||||
lk [ load k: n! (n-k)! k ]sx
|
||||
lfx [ call factorial; n! (n-k)! k! ]sx
|
||||
* [ multiply: n! (n-k)!k! ]sx
|
||||
/ [ divide: n!/(n-k)!k! ]sx
|
||||
] sb
|
||||
|
||||
5 3 lb x p [print(5 choose 3)]sx
|
||||
Loading…
Add table
Add a link
Reference in a new issue