summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index bc086ae9..713034c7 100644
--- a/hash.c
+++ b/hash.c
@@ -65,6 +65,7 @@ struct hash_iter {
};
val weak_keys_k, weak_vals_k, equal_based_k;
+val hash_construct_s;
/*
* Dynamic list built up during gc.
@@ -580,9 +581,22 @@ val hashv(val args)
return make_hash(wkeys, wvals, equal);
}
+val hash_construct(val hashv_args, val pairs)
+{
+ val hash = hashv(hashv_args);
+
+ for (; pairs; pairs = cdr(pairs)) {
+ val pair = car(pairs);
+ sethash(hash, first(pair), second(pair));
+ }
+
+ return hash;
+}
+
void hash_init(void)
{
weak_keys_k = intern(lit("weak-keys"), keyword_package);
weak_vals_k = intern(lit("weak-vals"), keyword_package);
equal_based_k = intern(lit("equal-based"), keyword_package);
+ hash_construct_s = intern(lit("hash-construct"), user_package);
}