Example #1
0
 public function testTakeAllAAndBStream()
 {
     $f = aAndB();
     $d = $f(emptyState());
     $this->assertEquals('((((#(1) . 5) . ((#(0) . 7))) . 2) . ((((#(1) . 6) . ((#(0) . 7))) . 2)))', sprintf('%s', takeAll($d)));
 }
Example #2
0
function runStar($g)
{
    return map('MicroKanren\\Core\\reifyFirst', takeAll(callGoal(fresh($g))));
}
Example #3
0
/**
 * Returns all results from a stream.
 *
 * @param [Cons|callable] $d a stream
 */
function takeAll($d)
{
    $d = pull($d);
    if (isNull($d)) {
        return nil();
    } else {
        return cons(car($d), takeAll(cdr($d)));
    }
}