PLT Scheme: Evaluate a string, or list of strings?
If I do a:
(regexp-split (regexp " ") "look tom")
I get
("look" "tom")
Which is fine, but I can't eval that. If I try to (eval-string) it [which is inside mzlib/string], it errors out, saying that 'tom' isn't defined. I guess it's trying to run:
(look tom)
Which isn't开发者_StackOverflow社区 correct either. Any tips here?
It is unclear what functionality you are looking for.
Are you trying to run:
(look)
(tom)
If look and tom are defined as functions you can use something like:
(define (look) 1)
(define (tom) 1)
(map (lambda (s) (apply (eval (string->symbol s)) '())) '("look" "tom"))
Or if look and tom are variables and you want to replace them with their values:
(define look 1)
(define tom 1)
(map (lambda (s) (eval (string->symbol s))) '("look" "tom"))
If you are trying to evaluate (look tom) then:
(define (look arg) arg)
(define tom 'arg)
(eval (map string->symbol '("look" "tom")))
Also you probably would have gotten a response to your question before now if you had also tagged the post scheme.
精彩评论