Name: Anonymous 2010-11-18 17:31
I'm trying to demonstrate to someone a simple case dispatch on a list.
The idea is something like:
(define (math x y)
(unquote (get-math x) y))
Where y is a list and:
(define (get-math x)
(cond ((= x 1) '+)
((= x 2) '-)
((= x 3) '*)
((= x 4) '/)))
But, Racket just doesn't use normal quoting rules, like I can only unquote if I'm already in a quote, but I can't pass an unquote to an argument, or nor use unquote in a definition without being a quote anyways, which is RETARDED.
tl;dr quote comes BEFORE unquoting, what do?
The idea is something like:
(define (math x y)
(unquote (get-math x) y))
Where y is a list and:
(define (get-math x)
(cond ((= x 1) '+)
((= x 2) '-)
((= x 3) '*)
((= x 4) '/)))
But, Racket just doesn't use normal quoting rules, like I can only unquote if I'm already in a quote, but I can't pass an unquote to an argument, or nor use unquote in a definition without being a quote anyways, which is RETARDED.
tl;dr quote comes BEFORE unquoting, what do?