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.
If I just put in (math 1 (4 5)), (4 is no a valid operator, etc. If I put in (math 1 '(4 5)), there aren't any normal operators to remove the quote. Rackets quoting system is all fucked up, like you can only do (quasiquote (unquote (+ 1 2))) and it'll return 3, but if you try anything else it just shits the bed, like there's just no command to unquote a list.
Are you aware that quoting something doesn't return some kind of special quoted-datatype, but just a list/symbol, that you can't unquote something outside a quasiquotation because (unquote '(1 2 3)) and (unquote (list 1 2 3)) would be the same thing and that you should just return your fucking function, not the symbol and that if you really want to be a fucking faggot you should use eval? IHBT
Name:
Anonymous2010-11-19 2:33
>>1
What the fuck did you expect to have happen? It's like you have no idea what quote/quasiquote/unquote is for. Use apply, like the non-retarded anon above you.
I swear, some people would implement quoting in Kernel.