1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
function add_pn($type,$a,$v)
{
$outs=array();
$functions=array(
'prev'=>array(
'exp'=> create_function('$a,$b,&$c','return pow($a,$b);'),
'opr'=> create_function('$a,$b','return $a-$b;'),
'com'=> create_function('$a,$b','return max($a,$b);'),
'equ'=> create_function('$a,$b','return ($a > $b)? true:false;')
),
'next'=>array(
'exp'=> create_function('$a,$b,&$c','$c=$a*$c; return $c/10;'),
'opr'=> create_function('$a,$b','return $a+$b;'),
'com'=> create_function('$a,$b','return min($a,$b);'),
'equ'=> create_function('$a,$b','return ($a < $b)? true:false;')
)
);
foreach ($functions[$type] as $key => $val) ${$key}=$val;
$np=$this->mRows*$this->pnum;
$log=1;
while($v>=0)
{
$ww= $exp(10,$v,$log);
$value=$com($a, $opr($this->pnum,$ww));
if ($equ($this->pnum,$a))
{
$nk=$opr($np,($this->mRows*$ww));
$this->add(
max(1,$nk+1).'-'.min($nk+$this->mRows,$this->tRows),
$value,
sprintf("[%s]",$opr($this->pnum,$opr($ww,1)))
);
};
$v--;
}
} |
Partager