Does either the below `fun-now` or `make-fun-for-later` do what you want?

---- BEGIN CODE ----
#lang racket/base

(define conditional-actions
  (list (cons (lambda () (= 2 (+ 1 1)))
              (lambda () (display "first!\n")))
        (cons (lambda () (= 42 (* 2 21)))
              (lambda () (display "second!\n")))))

(define (fun-now lst)
  (for-each (lambda (pair)
              (and ((car pair))
                   ((cdr pair))))
            lst))

(display "fun-now...\n")
(fun-now conditional-actions)

(define (make-fun-for-later lst)
  (lambda ()
    (for-each (lambda (pair)
                (and ((car pair))
                     ((cdr pair))))
              lst)))

(display "make-fun-for-later...\n")
(define fun-later (make-fun-for-later conditional-actions))
(display "fun-later...\n")
(fun-later)
---- END CODE ----

---- BEGIN OUTPUT ----
fun-now...
first!
second!
make-fun-for-later...
fun-later...
first!
second!
---- END OUTPUT ----

I gave this kind of example of using procedures because I don't know whether you're already familiar with how to use procedures/closures like this.

Neil V.

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to