Example #1
0
function encode_node($node)
{
    $literals = [null => 'nil', true => 'true', false => 'false'];
    if (is_literal($node) && isset($literals[$node])) {
        return $literals[$node];
    }
    if (is_character($node)) {
        return encode_character($node);
    }
    if (is_string($node)) {
        return encode_string($node);
    }
    if ($node instanceof Keyword) {
        return ':' . encode_symbol($node);
    }
    if ($node instanceof Symbol) {
        return encode_symbol($node);
    }
    if (is_int($node) || is_float($node)) {
        return $node;
    }
    if ($node instanceof LinkedList) {
        return encode_list($node);
    }
    if ($node instanceof Vector) {
        return encode_vector($node);
    }
    if ($node instanceof Map) {
        return encode_map($node);
    }
    if ($node instanceof Set) {
        return encode_set($node);
    }
    if ($node instanceof Tagged) {
        return encode_tagged($node);
    }
    if (is_array($node)) {
        return !count($node) || isset($node[0]) ? encode_list(new \ArrayIterator($node)) : encode_map(convert_assoc_to_map($node));
    }
    throw new \InvalidArgumentException(sprintf('Cannot encode node of type %s.', gettype($node)));
}
Example #2
0
            </div>
        </div>
    </div>
    <section id="map">
    	<?php 
foreach ($map_grid as $y => $r) {
    ?>
        <ul id="<?php 
    echo 'y' . $y;
    ?>
">
        <?php 
    foreach ($r as $x => $c) {
        ?>
            <?php 
        $p_id = is_character($x, $y);
        $type = (int) $c;
        $subtype = $c * 10 - $type * 10;
        // check finish
        $is_finish_pos = $x == $finishx && $y == $finishy;
        $ground = $map_ground[$y][$x];
        switch ((int) $ground) {
            default:
            case 0:
                $texture = 'none';
                break;
                // no road
            // no road
            case 1:
                $texture = 'concrete';
                break;