Example #1
0
def test_condeseq():
    x = var('x')
    assert set(run(0, x, condeseq(([eq(x, 2)], [eq(x, 3)])))) == {2, 3}
    assert set(run(0, x, condeseq([[eq(x, 2), eq(x, 3)]]))) == set()

    goals = ([eq(x, i)] for i in count())  # infinite number of goals
    assert run(1, x, condeseq(goals)) == (0, )
    assert run(1, x, condeseq(goals)) == (1, )
Example #2
0
def prime_check(x):
    '''
    if is a variable
    '''
    if isvar(x):
        '''
        return the sequence of prime numbers
        '''
        return condeseq([(eq, x, p)] for p in map(prime, it.count(1)))
    else:
        '''
        else if is successful then check is prime and if is not then it fails
        '''
        return success if isprime(x) else fail
def check_prime(x):
    if isvar(x):
        return condeseq([eq(x, p)] for p in map(prime, it.count(1)))
    else:
        return success if isprime(x) else fail
Example #4
0
def prime_check(x):
    if isvar(x):
        return condeseq([(eq, x, p)] for p in map(prime, it.count(1)))
    else:
        return success if isprime(x) else fail
def prime_test(n):
    if isvar(n):
        return condeseq([(eq, n, p)] for p in map(prime, it.count(1)))
    else:
        return success if isprime(n) else fail
Example #6
0
def primo(x):
    """ x is a prime number """
    if isvar(x):
        return condeseq([(eq, x, p)] for p in map(sg.prime, it.count(1)))
    else:
        return success if sg.isprime(x) else fail
Example #7
0
def primo(x):
    """ x is a prime number """
    if isvar(x):
        return condeseq([(eq, x, p)] for p in it.imap(prime, it.count(1)))
    else:
        return success if isprime(x) else fail