diff --git a/include/mes/builtins.h b/include/mes/builtins.h index 14f0f8a6..fed49aef 100644 --- a/include/mes/builtins.h +++ b/include/mes/builtins.h @@ -73,6 +73,7 @@ struct scm *hash_table_printer (struct scm *table); struct scm *make_hash_table (struct scm *x); struct scm *hash_table_p (struct scm *x); struct scm *hash_map_to_list (struct scm *proc, struct scm *table); +struct scm *hash_clear_x (struct scm *table); /* src/lib.c */ struct scm *type_ (struct scm *x); struct scm *car_ (struct scm *x); diff --git a/src/builtins.c b/src/builtins.c index 5b5dee69..e50214aa 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -183,6 +183,7 @@ mes_builtins (struct scm *a) /*:((internal)) */ a = init_builtin (builtin_type, "hash-table?", 1, &hash_table_p, a); a = init_builtin (builtin_type, "make-hash-table", -1, &make_hash_table, a); a = init_builtin (builtin_type, "hash-map->list", 2, &hash_map_to_list, a); + a = init_builtin (builtin_type, "hash-clear!", 1, &hash_clear_x, a); /* src/lib.c */ a = init_builtin (builtin_type, "core:type", 1, &type_, a); a = init_builtin (builtin_type, "core:car", 1, &car_, a); diff --git a/src/hash.c b/src/hash.c index f898b41e..7e9187de 100644 --- a/src/hash.c +++ b/src/hash.c @@ -248,3 +248,13 @@ hash_map_to_list (struct scm *proc, struct scm *table) } return lst; } + +struct scm * +hash_clear_x (struct scm *table) +{ + struct scm *s = struct_ref_ (table, 3); + long size = s->value; + struct scm *buckets = make_vector_ (size, cell_unspecified); + struct_set_x_ (table, 4, buckets); + return cell_unspecified; +}