[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] lambda's in a hash table
From: |
Claude Marinier |
Subject: |
[Chicken-users] lambda's in a hash table |
Date: |
Fri, 4 Apr 2014 19:54:02 -0400 (EDT) |
User-agent: |
Alpine 2.02 (DEB 1266 2009-07-14) |
Bonjour,
I can add lambdas to a hash table at run time, retrieve them, and execute
them. This is very useful.
I would like to have the compiler do some of this for me. I probably
cannot write a literal hash table but I expected to be able to write a
literal association list. I have tried this but it does not work.
(declare (uses srfi-69))
(define a-list
`(
(dot . ,(lambda () (display "dot\n")))
(dash . ,(lambda () (display "dash\n")))
))
(define dict
(alist->hash-table a-list))
(let ((func-dot (hash-table-ref dict 'dot))
(func-dash (hash-table-ref dict 'dash)))
func-dot
func-dash)
I have tried various ways of quoting but have not yet found something
which works.
Can this be done or do I have to create it when the program starts?
Merci.
--
Claude Marinier
- [Chicken-users] lambda's in a hash table,
Claude Marinier <=