コード例 #1
0
    $stream->write('Message 4');
    (yield '2 messages written');
    $stream->write('Message 5');
    $stream->write('Message 6');
    (yield '2 messages written');
}
function reader(InputStream $stream)
{
    foreach ($stream as $line) {
        if (strlen($line)) {
            (yield $line);
        } else {
            $stream->close();
        }
    }
}
$stream = new InputStream();
$queue[] = writer($stream);
$queue[] = reader($stream);
while (true) {
    $continue = array_reduce($queue, function ($result, Iterator $queueItem) {
        if ($valid = $queueItem->valid()) {
            echo $queueItem->current() . PHP_EOL;
            $queueItem->next();
        }
        return $result || $valid;
    }, false);
    if (!$continue) {
        break;
    }
}
コード例 #2
0
ファイル: writer.lib.php プロジェクト: Anathemch/GIT
                $l += 13;
            } else {
                $l++;
            }
        } else {
            //->gerade
            if ($a < 4) {
                $l += 12;
            } else {
                $l += (23 - 3 * 8) * $op;
            }
            $a += $op;
        }
    }
    //Kehrung
    $l = 0;
    while (isset($string[$l])) {
        $string[$l] = strtolower($string[$l]);
        $l++;
    }
    $l--;
    $string[$l] = strtoupper($string[$l]);
    while (isset($string[$l])) {
        $returnstring .= $string[$l];
        $l--;
    }
    // omg:
    return $returnstring;
}
echo writer();