From: John L. Stein
Subject: Trouble using variables for function names in function declarations
Date:
Message-ID: <55obcb$c9i@uni.library.ucla.edu>
Trouble using variables for function names in function declarations
The following function works and creates an object called op.
(define op (make <text-item>
:parent c
:coords (text-coords e)
:text "<"
:fill "red"
:anchor "w"))
But I want to make a bunch of such objects so I want op to be
a variable. So I tried to define the following make-text-item!
function (2nd line). It attempts to get the symbol for each
element e and make an object with that name.
The function (get-symbol! e) defined in the first line is used
to find the symbol for e. It works fine by itself. It produces
a distinct symbol (eg. blu rf th yh etc.) for each e.
The combined function (make-text-item! e) does not work
however. Can anbody tell me how to fix it or better yet
provide an example?
Thanks
-js
(define (get-symbol! e) (string->symbol (get-name! e)))
(define (make-text-item! e)
(define (get-symbol! e) (make <text-item>
:parent c
:coords (text-coords e)
:text "<"
:fill "red"
:anchor "w"))
)
(define (make-text-items! gr)
(map (lambda (x) (make-text-item! x)) (set-edge->list (edges gr))))