our
$VERSION
=
'0.061_002'
;
sub
api_version() { 2 }
sub
CLONE_SKIP { 1 }
'+'
=>
sub
{
my
$class
=
ref
$_
[0];
my
$x
=
$class
-> _copy(
$_
[0]);
my
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
return
$class
-> _add(
$x
,
$y
);
},
'-'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _sub(
$x
,
$y
);
},
'*'
=>
sub
{
my
$class
=
ref
$_
[0];
my
$x
=
$class
-> _copy(
$_
[0]);
my
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
return
$class
-> _mul(
$x
,
$y
);
},
'/'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _div(
$x
,
$y
);
},
'%'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _mod(
$x
,
$y
);
},
'**'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _pow(
$x
,
$y
);
},
'<<'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$class
-> _num(
$_
[0]);
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$_
[0];
$y
=
ref
(
$_
[1]) ?
$class
-> _num(
$_
[1]) :
$_
[1];
}
return
$class
-> _blsft(
$x
,
$y
);
},
'>>'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _brsft(
$x
,
$y
);
},
'<'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _acmp(
$x
,
$y
) < 0;
},
'<='
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _acmp(
$x
,
$y
) <= 0;
},
'>'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _acmp(
$x
,
$y
) > 0;
},
'>='
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _acmp(
$x
,
$y
) >= 0;
},
'=='
=>
sub
{
my
$class
=
ref
$_
[0];
my
$x
=
$class
-> _copy(
$_
[0]);
my
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
return
$class
-> _acmp(
$x
,
$y
) == 0;
},
'!='
=>
sub
{
my
$class
=
ref
$_
[0];
my
$x
=
$class
-> _copy(
$_
[0]);
my
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
return
$class
-> _acmp(
$x
,
$y
) != 0;
},
'<=>'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _acmp(
$x
,
$y
);
},
'&'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _and(
$x
,
$y
);
},
'|'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _or(
$x
,
$y
);
},
'^'
=>
sub
{
my
$class
=
ref
$_
[0];
my
(
$x
,
$y
);
if
(
$_
[2]) {
$y
=
$_
[0];
$x
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
else
{
$x
=
$class
-> _copy(
$_
[0]);
$y
=
ref
(
$_
[1]) ?
$_
[1] :
$class
-> _new(
$_
[1]);
}
return
$class
-> _xor(
$x
,
$y
);
},
'abs'
=>
sub
{
$_
[0] },
'sqrt'
=>
sub
{
my
$class
=
ref
$_
[0];
return
$class
-> _sqrt(
$class
-> _copy(
$_
[0]));
},
'int'
=>
sub
{
$_
[0] -> copy() -> bint(); },
'bool'
=>
sub
{
ref
(
$_
[0]) -> _is_zero(
$_
[0]) ?
''
: 1; },
'""'
=>
sub
{
ref
(
$_
[0]) -> _str(
$_
[0]); },
'0+'
=>
sub
{
ref
(
$_
[0]) -> _num(
$_
[0]); },
'='
=>
sub
{
ref
(
$_
[0]) -> _copy(
$_
[0]); },
;
sub
import
{ }
sub
_check {
my
(
$class
,
$x
) =
@_
;
return
"Input is undefined"
unless
defined
$x
;
return
"$x is not a reference"
unless
ref
(
$x
);
return
0;
}
sub
_digit {
my
(
$class
,
$x
,
$n
) =
@_
;
substr
(
$class
->_str(
$x
), -(
$n
+1), 1);
}
sub
_num {
my
(
$class
,
$x
) =
@_
;
0 +
$class
-> _str(
$x
);
}
sub
_fac {
my
(
$class
,
$x
) =
@_
;
my
$two
=
$class
-> _two();
if
(
$class
-> _acmp(
$x
,
$two
) < 0) {
$class
->_set(
$x
, 1);
return
$x
;
}
my
$i
=
$class
-> _copy(
$x
);
while
(
$class
-> _acmp(
$i
,
$two
) > 0) {
$i
=
$class
-> _dec(
$i
);
$x
=
$class
-> _mul(
$x
,
$i
);
}
return
$x
;
}
sub
_nok {
my
(
$class
,
$n
,
$k
) =
@_
;
{
my
$twok
=
$class
-> _mul(
$class
-> _two(),
$class
-> _copy(
$k
));
if
(
$class
-> _acmp(
$twok
,
$n
) > 0) {
$k
=
$class
-> _sub(
$class
-> _copy(
$n
),
$k
);
}
}
if
(
$class
-> _is_zero(
$k
)) {
return
$class
-> _one();
}
my
$n_orig
=
$class
-> _copy(
$n
);
$n
=
$class
-> _sub(
$n
,
$k
);
$n
=
$class
-> _inc(
$n
);
my
$f
=
$class
-> _copy(
$n
);
$class
-> _inc(
$f
);
my
$d
=
$class
-> _two();
while
(
$class
-> _acmp(
$f
,
$n_orig
) <= 0) {
$n
=
$class
-> _mul(
$n
,
$f
);
$n
=
$class
-> _div(
$n
,
$d
);
$f
=
$class
-> _inc(
$f
);
$d
=
$class
-> _inc(
$d
);
}
return
$n
;
}
sub
_log_int {
my
(
$class
,
$x
,
$base
) =
@_
;
return
if
$class
-> _is_zero(
$x
);
$base
=
$class
-> _new(2)
unless
defined
(
$base
);
$base
=
$class
-> _new(
$base
)
unless
ref
(
$base
);
return
if
$class
-> _is_zero(
$base
) ||
$class
-> _is_one(
$base
);
if
(
$class
-> _is_one(
$x
)) {
return
$class
-> _zero(), 1;
}
my
$cmp
=
$class
-> _acmp(
$x
,
$base
);
if
(
$cmp
== 0) {
return
$class
-> _one(), 1;
}
if
(
$cmp
< 0) {
return
$class
-> _zero(), 0;
}
my
$y
;
{
my
$x_str
=
$class
-> _str(
$x
);
my
$b_str
=
$class
-> _str(
$base
);
my
$xm
=
"."
.
$x_str
;
my
$bm
=
"."
.
$b_str
;
my
$xe
=
length
(
$x_str
);
my
$be
=
length
(
$b_str
);
my
$log10
=
log
(10);
my
$guess
=
int
((
log
(
$xm
) +
$xe
*
$log10
) / (
log
(
$bm
) +
$be
*
$log10
));
$y
=
$class
-> _new(
$guess
);
}
my
$trial
=
$class
-> _pow(
$class
-> _copy(
$base
),
$y
);
my
$acmp
=
$class
-> _acmp(
$trial
,
$x
);
return
$y
, 1
if
$acmp
== 0;
while
(
$acmp
< 0) {
$trial
=
$class
-> _mul(
$trial
,
$base
);
$y
=
$class
-> _inc(
$y
);
$acmp
=
$class
-> _acmp(
$trial
,
$x
);
}
while
(
$acmp
> 0) {
$trial
=
$class
-> _div(
$trial
,
$base
);
$y
=
$class
-> _dec(
$y
);
$acmp
=
$class
-> _acmp(
$trial
,
$x
);
}
return
$y
, 1
if
$acmp
== 0;
return
$y
, 0;
}
1;