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,75 @@
processor ChurchZero
templates apply&{f:}
$ !
end apply
end ChurchZero
def zero: $ChurchZero;
processor Successor
def predecessor: $;
templates apply&{f:}
$ -> predecessor::apply&{f: f} -> f !
end apply
end Successor
templates churchFromInt
@: $zero;
$ -> #
when <=0> do $@!
when <1..> do @: $@ -> Successor; $-1 -> #
end churchFromInt
templates intFromChurch
templates add1
$ + 1 !
end add1
def church: $;
0 -> church::apply&{f: add1} !
end intFromChurch
def three: $zero -> Successor -> Successor -> Successor;
def four: 4 -> churchFromInt;
processor Add&{to:}
def add: $;
templates apply&{f:}
$ -> add::apply&{f: f} -> to::apply&{f: f} !
end apply
end Add
$three -> Add&{to: $four} -> intFromChurch -> '$;
' -> !OUT::write
processor Multiply&{by:}
def multiply: $;
templates apply&{f:}
$ -> multiply::apply&{f: by::apply&{f: f}} !
end apply
end Multiply
$three -> Multiply&{by: $four} -> intFromChurch -> '$;
' -> !OUT::write
processor Power&{exp:}
def base: $;
templates apply&{f:}
processor Wrap&{f:}
templates function
$ -> f !
end function
end Wrap
templates compose
def p:$;
$Wrap&{f: base::apply&{f: p::function}} !
end compose
def pow: $Wrap&{f: f} -> exp::apply&{f: compose};
$ -> pow::function !
end apply
end Power
$three -> Power&{exp: $four} -> intFromChurch -> '$;
' -> !OUT::write
$four -> Power&{exp: $three} -> intFromChurch -> '$;
' -> !OUT::write

View file

@ -0,0 +1,58 @@
processor ChurchZero
templates apply&{f:}
$ !
end apply
end ChurchZero
def zero: $ChurchZero;
processor Successor
def predecessor: $;
templates apply&{f:}
$ -> predecessor::apply&{f: f} -> f !
end apply
end Successor
templates churchFromInt
@: $zero;
$ -> #
when <=0> do $@!
when <1..> do @: $@ -> Successor; $-1 -> #
end churchFromInt
templates intFromChurch
templates add1
$ + 1 !
end add1
def church: $;
0 -> church::apply&{f: add1} !
end intFromChurch
def three: $zero -> Successor -> Successor -> Successor;
def four: 4 -> churchFromInt;
templates add&{to:}
$ -> to::apply&{f: Successor} !
end add
$three -> add&{to: $four} -> intFromChurch -> '$;
' -> !OUT::write
templates multiply&{by:}
def m: $;
$zero -> by::apply&{f: add&{to: $m}} !
end multiply
$three -> multiply&{by: $four} -> intFromChurch -> '$;
' -> !OUT::write
templates power&{exp:}
def base: $;
$zero -> Successor -> exp::apply&{f: multiply&{by: $base}} !
end power
$three -> power&{exp: $four} -> intFromChurch -> '$;
' -> !OUT::write
$four -> power&{exp: $three} -> intFromChurch -> '$;
' -> !OUT::write