コード例 #1
0
ファイル: core.py プロジェクト: cherry-wb/logpy
def membero(x, coll):
    """ Goal such that x is an item of coll """
    if not isvar(x) and not isvar(coll):
        if x in coll:
            return success
        return (lany,) + tuple((eq, x, item) for item in coll)
    if isvar(x) and not isvar(coll):
        return (lany,) + tuple((eq, x, item) for item in coll)
    raise EarlyGoalError()
コード例 #2
0
ファイル: test_variable.py プロジェクト: sarvex/logpy
def test_isvar():
    assert not isvar(3)
    assert isvar(var(3))
コード例 #3
0
ファイル: test_variable.py プロジェクト: sarvex/logpy
def test_context_manager():
    with variables(1):
        assert isvar(1)
    assert not isvar(1)