Ejemplo n.º 1
0
def at_least(x,y):
    """is [x] at least [y]?"""
    compare(x,y)
    with pydwimmer.builtin.ints.first_larger():
        return yes()
    with pydwimmer.builtin.ints.are_equal():
        return yes()
Ejemplo n.º 2
0
def eq(x, y):
    """is [x] equal to [y]?"""
    x
    with double(z):
        y
        with double(w):
            return z == w
        with double_inc(w):
            raise core.probably(no())
        with zero():
            return z == 0
    with double_inc(z):
        y
        with double(w):
            raise core.probably(no())
        with double_inc(w):
            return z == w
        with zero():
            return core.probably(no())
    with zero():
        y
        with zero():
            return yes()
        with double(z):
            return z == 0
        with double_inc(z):
            raise core.probably(no())
    with pydwimmer.builtin.dicts.int_type():
        y
        with pydwimmer.builtin.dicts.int_type():
            return yes()
Ejemplo n.º 3
0
def greater(x,y):
    """is [x] greater than [y]?"""
    x
    with pydwimmer.builtin.ints.double_inc(x2):
        y
        with pydwimmer.builtin.ints.double(x3):
            compare_within_one(x2,x3)
            with pydwimmer.builtin.ints.second_larger():
                return no()
            with pydwimmer.builtin.ints.second_one_larger():
                return no()
            with pydwimmer.builtin.ints.are_equal():
                return yes()
        with pydwimmer.builtin.ints.double_inc(x3):
            greater(x2, x3)
            with pydwimmer.builtin.core.answer(A):
                return A
        with pydwimmer.builtin.ints.zero():
            compare_within_one(x2, 0)
            with pydwimmer.builtin.ints.are_equal():
                return yes()
    with pydwimmer.builtin.ints.double(x2):
        y
        with pydwimmer.builtin.ints.double(x3):
            greater(x2, x3)
            with pydwimmer.builtin.core.answer(A):
                return A
        with pydwimmer.builtin.ints.double_inc(x3):
            compare_within_one(x2, x3)
            with pydwimmer.builtin.ints.first_one_larger():
                return yes()
            with pydwimmer.builtin.ints.first_larger():
                raise first_larger()
    with pydwimmer.builtin.ints.zero():
        y
        with pydwimmer.builtin.ints.zero():
            return no()