[plt-scheme] scheme_make_hash_table

From: wayne at taxupdate.com (wayne at taxupdate.com)
Date: Tue Jan 10 23:31:17 EST 2006

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);

		     "(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;

count: 1
key: *, val: 3

What am I missing?


Posted on the users mailing list.