Translating...

This commit is contained in:
danogentili 2016-06-24 23:47:10 +02:00
parent 3ce36dff92
commit 6399888253
3 changed files with 25 additions and 8 deletions

Binary file not shown.

View File

@ -2,6 +2,19 @@
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libpy2php');
require_once ('libpy2php.php');
require_once ('random.php');
function everynth($array, $n) {
$result = array();
$i = -1;
foreach($array as $key => $value) {
if ($i++ == $n) {
$i = 0;
}
if($i == 0) {
$result[$key] = $value;
}
}
return $result;
}
function primesbelow($N) {
$correction = (($N % 6) > 1);
$N = [0 => $N, 1 => ($N - 1), 2 => ($N + 4), 3 => ($N + 3), 4 => ($N + 2), 5 => ($N + 1) ][($N % 6) ];
@ -10,14 +23,12 @@ function primesbelow($N) {
foreach (pyjslib_range(((pyjslib_int(pow($N, 0.5)) / 3) + 1)) as $i) {
if ($sieve[$i]) {
$k = ((3 * $i) + 1) | 1;
$sieve[(($k * $k) / 3), null, (2 * $k) ] = // finish this
([false] * ((((($N / 6) - (($k * $k) / 6)) - 1) / $k) + 1));
$sieve[(((($k * $k) + (4 * $k)) - ((2 * $k) * ($i % 2))) / 3), null, (2 * $k) ] = ([false] * ((((($N / 6) - (((($k * $k) + (4 * $k)) - ((2 * $k) * ($i % 2))) / 6)) - 1) / $k) + 1));
everynth(array_splice($sieve, floor($k*$k / 3)), 2*$k) = ([false] * ((((($N / 6) - (($k * $k) / 6)) - 1) / $k) + 1));
everynth(array_splice($sieve, floor((k*k + 4*k - 2*k*(i%2)) / 3)), 2*$k) = ([false] * ((((($N / 6) - (((($k * $k) + (4 * $k)) - ((2 * $k) * ($i % 2))) / 6)) - 1) / $k) + 1));
}
}
// finish this
return ([2, 3] + [(3 * $i + 1) | 1 for $i in range(1, floor($N/3) - $correction) if $sieve[$i]]
);
return ([2, 3] + array_map(function ($i, $sieve) { if($sieve[$i]) return (3 * $i + 1) | 1; }, pyjslib_range(1, (($N / 3) - $correction)), $sieve));
}
$smallprimeset = set(primesbelow(100000));
$_smallprimeset = 100000;

View File

@ -2,13 +2,19 @@
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libpy2php');
require_once ('libpy2php.php');
require_once ('argparse.php');
require_once ('mtproto.php');
require_once ('classes/shell.php');
if (($__name__ == '__main__')) {
$parser = py2php_kwargs_function_call('argparse::ArgumentParser', ['telepy'], ["description" => 'Python implementation of telegram API.']);
py2php_kwargs_method_call($parser, 'add_argument', ['command'], ["nargs" => '?', "choices" => (['cmd', 'dialog_list', 'contact_list'] + /* py2php.fixme listcomp unsupported. */
py2php_kwargs_method_call($parser, 'add_argument', ['command'], ["nargs" => '?', "choices" => (['cmd', 'dialog_list', 'contact_list'] + array_map(function($sub) { return "chat_" . $sub; }, ['info', 'add_user', 'add_user_to_chat', 'del_user', 'set_photo', 'rename'])
) ]);
py2php_kwargs_method_call($parser, 'add_argument', ['args'], ["nargs" => '*']);
$args = $parser->parse_args();
if (($args->command == null)) {
new TelepyShell()->cmdloop();
$newTelePyShell = new TelepyShell();
$newTelePyShell->cmdloop();
}
}