Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Church-numerals/J/church-numerals-1.j
Normal file
24
Task/Church-numerals/J/church-numerals-1.j
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
chget=: {{(0;1;1;1) {:: y}}
|
||||
|
||||
chset=: {{
|
||||
'A B'=.;y
|
||||
'C D'=.B
|
||||
'E F'=.D
|
||||
<A;<C;<E;<<.x
|
||||
}}
|
||||
|
||||
ch0=: {{
|
||||
if.0=#y do.y=.;:'>:' end. NB. replace empty gerund with increment
|
||||
0 chset y`:6^:2`''
|
||||
}}
|
||||
|
||||
apply=: `:6
|
||||
|
||||
chNext=: {{(1+chget y) chset y}}
|
||||
|
||||
chAdd=: {{(x +&chget y) chset y}}
|
||||
chSub=: {{(x -&chget y) chset y}}
|
||||
chMul=: {{(x *&chget y) chset y}}
|
||||
chExp=: {{(x ^&chget y) chset y}}
|
||||
int2ch=: {{y chset ch0 ''}}
|
||||
ch2int=: chget
|
||||
14
Task/Church-numerals/J/church-numerals-2.j
Normal file
14
Task/Church-numerals/J/church-numerals-2.j
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
three=: chNext^:3 ch0''
|
||||
four=: chNext^:4 ch0''
|
||||
sixtyfour=: four chExp three
|
||||
eightyone=: three chExp four
|
||||
four apply 1
|
||||
16
|
||||
chget three
|
||||
3
|
||||
chget four
|
||||
4
|
||||
chget sixtyfour
|
||||
64
|
||||
chget eightyone
|
||||
81
|
||||
11
Task/Church-numerals/J/church-numerals-3.j
Normal file
11
Task/Church-numerals/J/church-numerals-3.j
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
three apply 0
|
||||
3
|
||||
three apply 10
|
||||
13
|
||||
four=: 4 chset ch0 {{2*y}}`''
|
||||
chget four
|
||||
4
|
||||
four apply 0
|
||||
0
|
||||
four apply 10
|
||||
160
|
||||
9
Task/Church-numerals/J/church-numerals-4.j
Normal file
9
Task/Church-numerals/J/church-numerals-4.j
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
four=: 4 chset ch0 +:`''
|
||||
four apply 10
|
||||
160
|
||||
(three chSub four) apply 10
|
||||
5
|
||||
(sixtyfour chSub three chExp four) apply 10x^20
|
||||
762939453125000
|
||||
(sixtyfour chSub three chExp 4 chset ch0 5x&*`'') apply 10x^20
|
||||
131072000
|
||||
Loading…
Add table
Add a link
Reference in a new issue