Exemple #1
0
def hasheqv(args):
    if len(args) % 2 != 0:
        raise SchemeException(
            "hasheqv: key does not have a corresponding value")
    keys = [args[i] for i in range(0, len(args), 2)]
    vals = [args[i] for i in range(1, len(args), 2)]
    return make_simple_table(W_EqvHashTable, keys, vals)
Exemple #2
0
def make_hasheqv(pairs):
    lsts = values.from_list(pairs)
    keys = []
    vals = []
    for lst in lsts:
        if not isinstance(lst, values.W_Cons):
            raise SchemeException("make-hash: expected list of pairs")
        keys.append(lst.car())
        vals.append(lst.cdr())
    return make_simple_table(W_EqvHashTable, keys, vals)
Exemple #3
0
def make_immutable_hasheq(assocs):
    pairs = values.from_list(assocs)
    keys  = [None] * len(pairs)
    vals  = [None] * len(pairs)
    for i, pair in enumerate(pairs):
        if not isinstance(pair, values.W_Cons):
            raise SchemeException("make-immutable-hasheq: expected list of pairs")
        keys[i] = pair.car()
        vals[i] = pair.cdr()
    return make_simple_table(W_EqHashTable, keys, vals, immutable=True)
Exemple #4
0
def make_hasheqv(pairs):
    lsts = values.from_list(pairs)
    keys = []
    vals = []
    for lst in lsts:
        if not isinstance(lst, values.W_Cons):
            raise SchemeException("make-hash: expected list of pairs")
        keys.append(lst.car())
        vals.append(lst.cdr())
    return make_simple_table(W_EqvHashTable, keys, vals)
Exemple #5
0
def make_immutable_hasheq(assocs):
    pairs = values.from_list(assocs)
    keys = [None] * len(pairs)
    vals = [None] * len(pairs)
    for i, pair in enumerate(pairs):
        if not isinstance(pair, values.W_Cons):
            raise SchemeException(
                "make-immutable-hasheq: expected list of pairs")
        keys[i] = pair.car()
        vals[i] = pair.cdr()
    return make_simple_table(W_EqHashTable, keys, vals, immutable=True)
Exemple #6
0
def hasheqv(args):
    if len(args) % 2 != 0:
        raise SchemeException("hasheqv: key does not have a corresponding value")
    keys = [args[i] for i in range(0, len(args), 2)]
    vals = [args[i] for i in range(1, len(args), 2)]
    return make_simple_table(W_EqvHashTable, keys, vals, immutable=True)
Exemple #7
0
def make_immutable_hasheq(assocs):
    keys, vals = from_assocs(assocs, "make-immutable-hasheq")
    return make_simple_table(W_EqHashTable, keys, vals, immutable=True)
Exemple #8
0
def make_weak_hasheq():
    # FIXME: not actually weak
    return make_simple_table(W_EqvHashTable, None, None)
Exemple #9
0
def make_weak_hasheq():
    # FIXME: not actually weak
    return make_simple_table(W_EqvHashTable, [], [])