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)
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)
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)
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)
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)
def make_immutable_hasheq(assocs): keys, vals = from_assocs(assocs, "make-immutable-hasheq") return make_simple_table(W_EqHashTable, keys, vals, immutable=True)
def make_weak_hasheq(): # FIXME: not actually weak return make_simple_table(W_EqvHashTable, None, None)
def make_weak_hasheq(): # FIXME: not actually weak return make_simple_table(W_EqvHashTable, [], [])