Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Pi/Tailspin/pi.tailspin
Normal file
38
Task/Pi/Tailspin/pi.tailspin
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
use 'java:java.math' stand-alone
|
||||
|
||||
def zero: 0 -> math/BigInteger::valueOf;
|
||||
def one: 1 -> math/BigInteger::valueOf;
|
||||
def two: 2 -> math/BigInteger::valueOf;
|
||||
def three: 3 -> math/BigInteger::valueOf;
|
||||
def four: 4 -> math/BigInteger::valueOf;
|
||||
def seven: 7 -> math/BigInteger::valueOf;
|
||||
def ten: 10 -> math/BigInteger::valueOf;
|
||||
|
||||
templates g&{q:, r:, t:, k:, n:, l:}
|
||||
def u: $four -> q::multiply -> r::add;
|
||||
def nt: $n -> t::multiply;
|
||||
$ -> #
|
||||
when <?($t -> u::subtract <..~$nt>)> do
|
||||
$n -> !OUT::write
|
||||
$ -> \(<=1> $!\) -> '.' -> !OUT::write
|
||||
def v: $three -> q::multiply -> r::add -> ten::multiply;
|
||||
def quot: $t -> v::divide;
|
||||
0 -> g&{q: $ten -> q::multiply,
|
||||
r: $nt -> r::subtract -> ten::multiply,
|
||||
t: $t,
|
||||
k: $k,
|
||||
n: $ten -> n::multiply -> quot::subtract,
|
||||
l: $l } !
|
||||
otherwise
|
||||
def tl: $t -> l::multiply;
|
||||
def rl: $r -> l::multiply;
|
||||
def term: $q -> seven::multiply -> k::multiply -> two::add -> rl::add;
|
||||
$ -> g&{q: $q -> k::multiply,
|
||||
r: $two -> q::multiply -> r::add -> l::multiply,
|
||||
t: $tl,
|
||||
k: $k -> one::add,
|
||||
n: $tl -> term::divide,
|
||||
l: $l -> two::add} !
|
||||
end g
|
||||
|
||||
1 -> g&{q:$one, r:$zero, t:$one, k:$one, n:$three, l:$three} -> !VOID
|
||||
Loading…
Add table
Add a link
Reference in a new issue