38 lines
1.2 KiB
Text
38 lines
1.2 KiB
Text
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
|