Matthias has good points about why the base Racket language does not do
this, but if you want to do language experiments, or if you have really
unusual practical requirements, you can still use Racket as a language
platform...
You could define your own "#lang" variant of Racket that stores the
source syntax with the definition, so that you could do the dynamic
"normalize" at times but still use Racket's evaluator.
Neil V.
Scott Klarenbach wrote at 12/27/2013 06:27 PM:
I noticed that MIT Scheme has the "pp" procedure which prints the
source code of a given function. Is there an equivalent way to do
this in Racket?
More generally, I'm looking to normalize nested procedures to their
most rudimentary expressions.
For example:
(define (something? x) (> x 3))
(define (something-else? x) (< x 10))
(define (combined x) (and (something? x) (something-else? x)))
(normalize combined) =>
'(lambda (x) (and (> x 3) (< x 10)))
((normalize combined) 7) => #t
I'm sure it's not so simple and a robust general solution involves
some type of beta reduction and/or argument constraints, but I'm just
looking for a nudge in the right direction.
Thanks.
--
Talk to you soon,
Scott Klarenbach
PointyHat Software Corp.
www.pointyhat.ca <http://www.pointyhat.ca>
p 604-568-4280
e sc...@pointyhat.ca <mailto:sc...@pointyhat.ca>
200-1575 W. Georgia
Vancouver, BC V6G2V3
_______________________________________
To iterate is human; to recur, divine
____________________
Racket Users list:
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users