unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mikael Djurfeldt <djurfeldt@nada.kth.se>
Cc: djurfeldt@nada.kth.se, guile-devel@gnu.org
Subject: Re: How do I really do this?
Date: Sat, 06 Mar 2004 15:50:22 -0500	[thread overview]
Message-ID: <xy7n06tog35.fsf@nada.kth.se> (raw)
In-Reply-To: <40466FAF.3A286BB0@veritas.com> (Bruce Korb's message of "Wed, 03 Mar 2004 15:52:15 -0800")

Bruce Korb <bkorb@veritas.com> writes:

> I would like to be able to associate a value with a string.
> hash functions look perfect, except I can't use them unless
> I have a hash table and there isn't any clear way I've found
> to create hash table entries without having a hash table.
> I've tried:
>
>   (define (string->symbol (function-returning-string))
>           (value-function))
>
> I thought that to be really obvious, but I was wrong.
> If either of these mecanisms are documented somewhere,
> I'd gladly read it.  Meanwhile, can someone send me a hint?

(define t (make-hash-table))
(hash-set! t (function-returning-string) (value-function))

Then you can lookup values again with (hash-ref t <string>).

This is all documented in the Guile refence manual in the info node
'Hash Tables'.

You don't gain anything by trying to piggyback on 'define', because
'define' uses exactly the same hash table internally as that returned
by (make-hash-table).

M


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


  parent reply	other threads:[~2004-03-06 20:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-03 23:52 How do I really do this? Bruce Korb
2004-03-06 12:17 ` Neil Jerram
2004-03-06 17:43   ` Bruce Korb
2004-03-06 18:00     ` Neil Jerram
2004-03-10 21:07       ` Andreas Rottmann
2004-03-10 22:21       ` Carl Witty
2004-03-12 17:18         ` Bruce Korb
2004-03-11 14:54       ` Paul Jarc
2004-03-06 20:50 ` Mikael Djurfeldt [this message]
2004-03-07  1:33   ` Bruce Korb
2004-03-10 23:44   ` Marius Vollmer
2004-03-14  2:54     ` Bruce Korb
2004-03-08  2:27 ` Paul Jarc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xy7n06tog35.fsf@nada.kth.se \
    --to=djurfeldt@nada.kth.se \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).