Beispiel #1
0
def _list_to_swipy_ref(item: List, swipy_ref, lit_var_store: Dict[Variable, int]):
    clist_term = swipy.swipy_new_term_ref()

    swipy.swipy_put_nil(swipy_ref)
    args = item.get_arguments()
    for ind in range(len(args) - 1, -1, -1):
        _to_swipy_ref(args[ind], clist_term, lit_var_store)
        swipy.swipy_cons_list(swipy_ref, clist_term, swipy_ref)
Beispiel #2
0
def _list_to_swipy(item: List, lit_var_store: Dict[Variable, int]):
    list_term = swipy.swipy_new_term_ref()

    if len(item.get_arguments()) == 0:
        # if empty list
        swipy.swipy_put_nil(list_term)
    else:
        # if non-empty list
        clist_term = swipy.swipy_new_term_ref()

        swipy.swipy_put_nil(list_term)
        args = item.get_arguments()
        for ind in range(len(args) - 1, -1, -1):
            _to_swipy_ref(args[ind], clist_term, lit_var_store)
            swipy.swipy_cons_list(list_term, clist_term, list_term)

    return list_term