unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Somehow I have got this "thunk" thing wrong.
@ 2021-03-06  0:05 Tim Meehan
  2021-03-06  0:26 ` Christopher Baines
  2021-03-06  0:31 ` Olivier Dion via General Guile related discussions
  0 siblings, 2 replies; 8+ messages in thread
From: Tim Meehan @ 2021-03-06  0:05 UTC (permalink / raw)
  To: guile-user

I wanted to store a thunk in a hashtable so that I could look up its key
and then run it later. Something like this:

#! /usr/bin/guile
!#

(use-modules (ice-9 hash-table))

(define stuff (alist->hash-table
  '((a . (lambda () (display "event a\n")))
    (b . (lambda () (display "event b\n")))
    (c . (lambda () (display "event c\n"))))))

(define res (hash-ref stuff 'a))
(res)

But when I run it:
Wrong type to apply: (lambda () (display "event a\n"))


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-06 17:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-06  0:05 Somehow I have got this "thunk" thing wrong Tim Meehan
2021-03-06  0:26 ` Christopher Baines
2021-03-06  3:40   ` Tim Meehan
2021-03-06  3:43     ` Tim Meehan
2021-03-06  0:31 ` Olivier Dion via General Guile related discussions
2021-03-06  0:48   ` Aleix Conchillo Flaqué
2021-03-06 16:55   ` Taylan Kammer
2021-03-06 17:16     ` Olivier Dion via General Guile related discussions

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