atom.c
int atom_bound_in(atom_t* obj, atom_t* env) {
    if (!obj || !atom_is_container(obj)) {
        printf("\x1b[95m" "Fatal error: bound_in: bad object!\n" "\x1b[0m");
        exit(EXIT_FAILURE);
    } else if (!env || env->type != DICTIONARY) {
        printf("\x1b[95m" "Fatal error: bound_in: bad environment!\n" "\x1b[0m");
        exit(EXIT_FAILURE);
    }
    
    atom_t* owners = list();
    atom_get_owners_r(obj, owners);
    int bound = 0;
    atom_t* e;
    
    for (int i = 0; !bound && i < owners->val.list->len; ++i)
        for (e = env; e; e = e->val.dict->parent)
            if (owners->val.list->items[i] == e) {
                bound = 1;
                break;
            }
    
    list_free(owners);
    return bound;
}
/*
--------------------------------------
atom_bound_in

    Search if an object is reachable via a chain of enclosed environments.
--------------------------------------
*/
atom_bound_in
Search if an object is reachable via a chain of enclosed environments.
atom_bound_in Search if an object is reachable via a chain of enclosed environments .
int atom_bound_in(atom_t* obj, atom_t* env) {
    if (!obj || !atom_is_container(obj)) {
        printf("\x1b[95m" "Fatal error: bound_in: bad object!\n" "\x1b[0m");
        exit(EXIT_FAILURE);
    } else if (!env || env->type != DICTIONARY) {
        printf("\x1b[95m" "Fatal error: bound_in: bad environment!\n" "\x1b[0m");
        exit(EXIT_FAILURE);
    }
    atom_t* owners = list();
    atom_get_owners_r(obj, owners);
    int bound = 0;
    atom_t* e;
    for (int i = 0; !bound && i < owners->val.list->len; ++i)
        for (e = env; e; e = e->val.dict->parent)
            if (owners->val.list->items[i] == e) {
                bound = 1;
                break;
            }
    list_free(owners);
    return bound;
}
int atom_bound_in ( atom_t * obj , atom_t * env ) { if ( ! obj || ! atom_is_container ( obj ) ) { printf ( " \x1b " " \n " " \x1b " ) ; exit ( EXIT_FAILURE ) ; } else if ( ! env || env -> type != DICTIONARY ) { printf ( " \x1b " " \n " " \x1b " ) ; exit ( EXIT_FAILURE ) ; } atom_t * owners = list ( ) ; atom_get_owners_r ( obj , owners ) ; int bound = 0 ; atom_t * e ; for ( int i = 0 ; ! bound && i < owners -> val . list -> len ; ++ i ) for ( e = env ; e ; e = e -> val . dict -> parent ) if ( owners -> val . list -> items [ i ] == e ) { bound = 1 ; break ; } list_free ( owners ) ; return bound ; }
atom_bound_in
Search if an object is reachable via a chain of enclosed environments.
atom_bound_in Search if an object is reachable via a chain of enclosed environments .