guile-user
[Top][All Lists]
Advanced

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

Somehow I have got this "thunk" thing wrong.


From: Tim Meehan
Subject: Somehow I have got this "thunk" thing wrong.
Date: Fri, 5 Mar 2021 18:05:20 -0600

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


reply via email to

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