In order to add a vector to a hash table, you need to actually create said vector, and add it. For example,
(define table (make-hash)) ;; create new mutable hash table
(define vec (make-vector 10 5)) ;; create new vector
(hash-set! table 'myVector vec) ;; add vector to hash, key='myVector, value=vec
(hash-ref table 'myVector) ;; retrieve hash value for specified key
#(5 5 5 5 5 5 5 5 5 5)
Note that when using a quoted list, such as when you defined arguments
, the first element is actually a symbol, ie. 'myVector
. So, to refer to it as your hash key, you should add the quote on the name as: (function-get 'myVector)
.
Consider the following:
(define *function-table* (make-hash))
(define (function-get key)
(hash-ref *function-table* key))
(define (function-put! key value)
(hash-set! *function-table* key value))
(define arguments (list 'myVector (make-vector 10 5)))
((lambda (pair)
(function-put! (car pair) (cadr pair)))
arguments)
then you can have:
(vector-length (function-get 'myVector))
=> 10
EDIT: If arguments
is a list containing the name and size of the vector that needs to be created and added to the hash, then you can do the following:
(define arguments '(myVector 5))
((lambda (pair)
(function-put! (car pair) (make-vector (cadr pair))))
arguments)
then,
(function-get 'myVector)
=> #(0 0 0 0 0)
(vector-length (function-get 'myVector))
=> 5