Beispiel #1
0
def _pygp_to_structure(term):
    v1 = pygprolog.pygp_Mk_Variable()
    v2 = pygprolog.pygp_Mk_Variable()

    pygprolog.pygp_Builtin_Functor(term, v1, v2)

    functor = pygprolog.pygp_Rd_String(v1)
    arity = pygprolog.pygp_Rd_Integer(v2)
    args = []
    for i in range(1, arity+1):
        v = pygprolog.pygp_Mk_Variable()
        pygprolog.pygp_Builtin_Arg(pygprolog.pygp_Mk_Integer(i), term, v)
        args.append(_read_pygp(v))

    # global global_context

    return Structure(c_functor(functor, arity), args)
Beispiel #2
0
def _num_to_pygp(value: Union[int, float]):
    if isinstance(value, int):
        return pygprolog.pygp_Mk_Integer(value)
    else:
        return pygprolog.pygp_Mk_Float(value)