Esempio n. 1
0
/**
 * Searches for a variable's value in the substitution. If a non-variable term
 * is walked, return that term.
 *
 * @param mixed $u a variable or non-variable term
 * @param Cons  $s the substitution
 */
function walk($u, $s)
{
    if (isVariable($u)) {
        $pr = assp(function ($v) use($u) {
            return isVariableEquals($u, $v);
        }, $s);
        if ($pr) {
            return walk(cdr($pr), $s);
        } else {
            return $u;
        }
    } else {
        return $u;
    }
}
Esempio n. 2
0
if($argv[1]=="--vboxwebsrv"){echo "\n".virtualbox_webserv();exit;}
if($argv[1]=="--tftpd"){echo "\n".tftpd();exit;}
if($argv[1]=="--vdi"){echo "\n".virtualbox_webserv()."\n".tftpd()."\n".dhcpd_server();exit;}
if($argv[1]=="--crossroads"){echo "\n".crossroads();exit;}
if($argv[1]=="--artica-status"){echo "\n".artica_status();exit;}
if($argv[1]=="--artica-executor"){echo "\n".artica_executor();exit;}
if($argv[1]=="--artica-background"){echo "\n".artica_background();exit;}
if($argv[1]=="--pptpd"){echo "\n".pptpd();exit;}
if($argv[1]=="--pptpd-clients"){echo "\n".pptp_clients();exit;}
if($argv[1]=="--bandwith"){echo "\n".bandwith();exit;}
if($argv[1]=="--apt-mirror"){echo "\n".apt_mirror();exit;}
if($argv[1]=="--squidclamav-tail"){echo "\n".squid_clamav_tail();exit;}
if($argv[1]=="--ddclient"){echo "\n".ddclient();exit;}
if($argv[1]=="--cluebringer"){echo "\n".cluebringer();exit;}
if($argv[1]=="--apachesrc"){echo "\n".apachesrc();exit;}
if($argv[1]=="--assp"){echo "\n".assp();exit;}
if($argv[1]=="--freewebs"){echo "\n".apachesrc()."\n".pure_ftpd();exit;}
if($argv[1]=="--openvpn"){echo "\n".openvpn();exit;}
if($argv[1]=="--vboxguest"){echo "\n".vboxguest();exit;}
if($argv[1]=="--sabnzbdplus"){echo "\n".sabnzbdplus();exit;}
if($argv[1]=="--openvpn-clients"){echo "\n".OpenVPNClientsStatus();exit;}
if($argv[1]=="--stunnel"){echo "\n".stunnel();exit;}
if($argv[1]=="--meta-checks"){echo "\n".meta_checks();exit;}
if($argv[1]=="--smbd"){echo "\n".smbd();exit;}
if($argv[1]=="--vnstat"){echo "\n".vnstat();exit;}
if($argv[1]=="--munin"){echo "\n".munin();exit;}
if($argv[1]=="--autofs"){echo "\n".autofs();exit;}
if($argv[1]=="--greyhole"){echo "\n".greyhole();exit;}
if($argv[1]=="--amavis-watchdog"){echo "\n".AmavisWatchdog();exit;}
if($argv[1]=="--dnsmasq"){echo "\n".dnsmasq();exit;}
if($argv[1]=="--iscsi"){echo "\n".iscsi();exit;}
Esempio n. 3
0
    exit;
}
if ($argv[1] == "--ddclient") {
    echo "\n" . ddclient();
    exit;
}
if ($argv[1] == "--cluebringer") {
    echo "\n" . cluebringer();
    exit;
}
if ($argv[1] == "--apachesrc") {
    echo "\n" . apachesrc();
    exit;
}
if ($argv[1] == "--assp") {
    echo "\n" . assp();
    exit;
}
if ($argv[1] == "--freewebs") {
    echo "\n" . apachesrc() . "\n" . pure_ftpd() . "\n" . tomcat();
    exit;
}
if ($argv[1] == "--openvpn") {
    echo "\n" . openvpn();
    exit;
}
if ($argv[1] == "--vboxguest") {
    echo "\n" . vboxguest();
    exit;
}
if ($argv[1] == "--sabnzbdplus") {
Esempio n. 4
0
 public function testAsspDoesNotCopy()
 {
     $a = cons(1, 'a');
     $b = cons(2, 'b');
     $list = alist($a, $b);
     $isEven = function ($x) {
         return $x % 2 === 0;
     };
     $isOdd = function ($x) {
         return $x % 2 !== 0;
     };
     $this->assertSame($a, assp($isOdd, $list));
     $this->assertSame($b, assp($isEven, $list));
 }
Esempio n. 5
0
/**
 * Returns the first element of a list for whose car a procedure returns true
 * or false if no match is found.
 *
 * @param callable $proc  a function that takes one argument and returns a
 *                        boolean
 * @param Cons     $alist an association list of key-value pairs
 */
function assp($proc, $alist)
{
    if (isPair($alist)) {
        $car = car($alist);
        try {
            $x = car($car);
        } catch (\InvalidArgumentException $e) {
            throw new \InvalidArgumentException("improperly formed alist {$alist}");
        }
        if ($proc($x)) {
            return $car;
        } else {
            return assp($proc, cdr($alist));
        }
    } else {
        return false;
    }
}