#lisp - Sun 13 May 2007 between 10:10 and 10:20

Krystof"the challenge"?
filcab42I have a teacher that has years (decades ;)) of experience lisp. and, in a forum thread, he gave us a challenge
faxyou could just make it a normal macro (interpolate "blah blah")
filcab42to write a function (interpolate "...")
Krystofit might then be his point that you can't write such a function
(and since this is homework or something like it, it's probably better that you have another go yourself)
it's not homework
faxKrystof: it is possible
filcab42At my university we have a forum where for students. some teachers visit it and we have some threads about lisp
lisppastefax pasted "get-symbol-value macro" at http://paste.lisp.org/display/41150
filcab42we have some meetings about lisp, also. A lisp group
faxfilcab42: wish we had that :/ all I have is 'Make a picture of a traffic light in java'
filcab42and someone created a thread about lisp macros. this challenge appeared in the middle of that thread ;)
faxits totally possible
Krystofoh yeah?
faxprobaly use read-from-string
filcab42Java... ugh
Krystoffax: maybe you need to try filcab42's exercise, too
faxprobably :|
Krystofwrite a function interpolate which takes a string and returns the string with variables from the lexical environment interpolated
test case: (let ((a 42)) (interpolate "$a")) => "42"
filcab42I have a solution that works... with the exception of those "let" cases ;)
Krystofgood luck
filcab42thanks ;)
Krystoffilcab42: you are getting closer to enlightenment
second test case, just in case it's not yet clear: (let ((fun #'interpolate) (a 42)) (funcall fun "$a")) => "42"
lisppastefax annotated #41150 with "spec1 done" at http://paste.lisp.org/display/41150#1
faxKrystof: you cant funcall a macro
yes thats what I meant to say
Krystofindeed. Which is why the specification that interpolate is a _function_ is important
no one said it has to be a function :/
Krystofyes they did
<filcab42> to write a function (interpolate "...")
faxwell I agree you certainly cant write a function to do it

Page: 2 9 16