コード例 #1
0
function appendo2($l, $s, $out)
{
    return disj(conj(eq(nil(), $l), eq($s, $out)), callFresh(function ($a) use($l, $s, $out) {
        return callFresh(function ($d) use($a, $l, $s, $out) {
            return conj(eq(cons($a, $d), $l), callFresh(function ($res) use($a, $d, $s, $out) {
                return conj(function ($sC) use($d, $s, $res) {
                    return function () use($d, $s, $res, $sC) {
                        $f = appendo2($d, $s, $res);
                        return $f($sC);
                    };
                }, eq(cons($a, $res), $out));
            }));
        });
    }));
}
コード例 #2
0
 public function create()
 {
     $post = nil(Post::class);
     $groups = (new PostService())->getGroupList();
     return view('admin.posts.create', compact('post', 'groups'));
 }
コード例 #3
0
ファイル: CoreTest.php プロジェクト: mudge/php-microkanren
 public function testMzero()
 {
     $this->assertEquals(nil(), mzero());
 }
コード例 #4
0
ファイル: LispTest.php プロジェクト: mudge/php-microkanren
 public function testMapOverNil()
 {
     $isOdd = function ($x) {
         return $x % 2 !== 0;
     };
     $this->assertEquals(nil(), map($isOdd, nil()));
 }
コード例 #5
0
ファイル: Lisp.php プロジェクト: mudge/php-microkanren
/**
 * Returns a list constructed of nested cons cells from the given arguments.
 * A convenience function equivalent to Scheme's list.
 *
 * e.g. list(1, 2, 3) is the same as cons(1, cons(2, cons(3, nil())))
 *
 * @param mixed $elements the elements of the list
 */
function alist()
{
    $elements = func_get_args();
    $length = func_num_args();
    $list = nil();
    for ($i = $length - 1; $i >= 0; $i -= 1) {
        $list = cons($elements[$i], $list);
    }
    return $list;
}
コード例 #6
0
ファイル: Core.php プロジェクト: mudge/php-microkanren
function reifyFirst($sC)
{
    $v = walkStar(variable(0), car($sC));
    return walkStar($v, reifyS($v, nil()));
}