[ssax-sxml] feature of attribute building: automatic joining of (cdr attribute-list)
Brought to you by:
oleg
From: Terrence B. <met...@ur...> - 2004-07-12 21:46:32
|
I was looking through some source code and came across this: (cvs-ref *macro* . ,(lambda (tag path) `(a (@ (href "http://cvs.sourceforge.net/viewcvs.py/kanren/kanren/" ,path)) (code ,path)))) 1/ I learned something. It appears that an attribute is built from a list. The first element is the attribute name. The attribute value is formed by joining together the remaining attributes. That's why the list starting with href about can have three elements. I was used to only having two elements in the list: one as the name and one as the value. Example of newly discovered functionality: > (define path1 "/src/beta/") > (define path2 "2004/12/") > (define file "distro.tar.gz") > (define anchor `(a (@ (href "http://www.x.com" ,path1 ,path2 ,file)))) > anchor (a (@ (href "http://www.x.com" "/src/beta/" "2004/12/" "distro.tar.gz"))) > (SXML->HTML anchor) <a href="http://www.x.com/src/beta/2004/12/distro.tar.gz">#t > 2/ I notice that the *macro* qualifier was used when rewriting a cvs-ref tag. Correct me if I'm wrong, but I believe the reason this is done is so that the code tag can be properly expanded. -- (let recur ((lis x) (k k)) (if (zero? k) (values '() lis) (receive (prefix suffix) (recur (cdr lis) (- k 1)) (values (cons (car lis) prefix) suffix))))) |