[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I really do this?

From: Neil Jerram
Subject: Re: How do I really do this?
Date: 06 Mar 2004 18:00:08 +0000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Bruce Korb <address@hidden> writes:

> How do I get a hash table started?  I've grepped throught he
> ice-9 code and I'm sure something's in there.  But looking at
> code around 'hash-create' and 'hashq-create' or even just "hash"
> didn't yield anything that worked.  I guess I just need something
> really explicit, like:
>    (define my-hash-table (hash-table-create))
> except that doesn't work.  What does?

The procedure you want is `make-hash-table':

guile> (help make-hash-table)
`make-hash-table' is a primitive procedure in the (guile) module.

 - Scheme Procedure: make-hash-table [n]
     Make a hash table with optional minimum number of buckets N

Note also that you might have found this using `apropos':

guile> (apropos "hash")
(guile): hashq  #<primitive-procedure hashq>
(guile): hashv  #<primitive-procedure hashv>
(guile): hash   #<primitive-procedure hash>
(guile): make-hash-table        #<primitive-procedure make-hash-table>
(guile): make-weak-key-hash-table       #<primitive-procedure 
(guile): make-weak-value-hash-table     #<primitive-procedure 
(guile): make-doubly-weak-hash-table    #<primitive-procedure 
(guile): hash-table?    #<primitive-procedure hash-table?>
(guile): weak-key-hash-table?   #<primitive-procedure weak-key-hash-table?>
(guile): weak-value-hash-table? #<primitive-procedure weak-value-hash-table?>
(guile): doubly-weak-hash-table?        #<primitive-procedure 
(guile): hash-clear!    #<primitive-procedure hash-clear!>
(guile): hashq-get-handle       #<primitive-procedure hashq-get-handle>
(guile): hashq-create-handle!   #<primitive-procedure hashq-create-handle!>
(guile): hashq-ref      #<primitive-procedure hashq-ref>
(guile): hashq-set!     #<primitive-procedure hashq-set!>
(guile): hashq-remove!  #<primitive-procedure hashq-remove!>
(guile): hashv-get-handle       #<primitive-procedure hashv-get-handle>
(guile): hashv-create-handle!   #<primitive-procedure hashv-create-handle!>
(guile): hashv-ref      #<primitive-procedure hashv-ref>
(guile): hashv-set!     #<primitive-procedure hashv-set!>
(guile): hashv-remove!  #<primitive-procedure hashv-remove!>
(guile): hash-get-handle        #<primitive-procedure hash-get-handle>
(guile): hash-create-handle!    #<primitive-procedure hash-create-handle!>
(guile): hash-ref       #<primitive-procedure hash-ref>
(guile): hash-set!      #<primitive-procedure hash-set!>
(guile): hash-remove!   #<primitive-procedure hash-remove!>
(guile): hashx-get-handle       #<primitive-procedure hashx-get-handle>
(guile): hashx-create-handle!   #<primitive-procedure hashx-create-handle!>
(guile): hashx-ref      #<primitive-procedure hashx-ref>
(guile): hashx-set!     #<primitive-procedure hashx-set!>
(guile): hash-fold      #<primitive-procedure hash-fold>
(guile): hash-for-each  #<primitive-procedure hash-for-each>
(guile): hash-for-each-handle   #<primitive-procedure hash-for-each-handle>
(guile): hash-map->list #<primitive-procedure hash-map->list>
(guile): symbol-hash    #<primitive-procedure symbol-hash>
(guile): read-hash-procedures
(guile): read-hash-extend       #<primitive-procedure read-hash-extend>
(guile): source-whash

> OK.  This works:
>    (define sym-name (value-function))
> So, why doesn't this:
>    (define (string->symbol "sym-name") (val-func))

Because this is the syntax for defining a procedure, and needs to be
one of:

(define (string->symbol) ...)
(define (string->symbol ARG1 ...) ...)
(define (string->symbol . ARGS) ...)

where all the ARGs must be symbols (not strings).

Also, string->symbol is already defined, so why are you trying to
redefine it?

Perhaps you're not trying to redefine it?  In which case, I still
don't understand what you are trying to do.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]