[plt-scheme] scheme_make_hash_table
I expected this code to declare a hash table, then insert 2 values in it.
Instead it looks like 1 value is inserted, and it's the wrong one.
-------------------------------
#include "scheme.h"
int main(int argc, char ** args)
{
Scheme_Env * env = scheme_basic_env();
Scheme_Hash_Table * hash = scheme_make_hash_table(SCHEME_hash_string);
scheme_add_global("*hash*", (Scheme_Object *)hash, env);
scheme_eval_string(
"(hash-table-put! *hash* \"a\" 1)"
"(hash-table-put! *hash* \"b\" 2)"
, env);
printf("count: %d\n", hash->count);
for (int i=0; i<hash->size; i++){
if (hash->vals[i])
printf("key: %s, val: %d\n", hash->keys[i], hash->vals[i]);
}
return 0;
}
-------------------------------
prints:
count: 1
key: *, val: 3
What am I missing?
Wayne