chickadee » sxml-transforms » pre-post-order*

pre-post-order* tree bindingsprocedure

Variant of pre-post-order which calls its handlers with only two arguments, TAG (the trigger symbol) and BODY (the subtree body):

(handler (car tree) (cdr tree))

In contrast, pre-post-order calls its handlers with the trigger symbol and with one argument for each element of the body:

(apply handler (car tree) (cdr tree))

On Chicken, pre-post-order is inefficient and will even fail if the tree length is greater than the native apply parameter limit, which may be as low as 126 depending on your system. We recommend using pre-post-order* to avoid these issues.

An example:

 ;; Convert generic lists to ordered HTML lists
   `(list "one" "two" (strong "three!"))
   `((list . ,(lambda (tag . body)
                (cons 'ol (map (lambda (x) (list 'li x)) body))))

now becomes:

 ;; Convert generic lists to ordered HTML lists, no limits!
   `(list "one" "two" (strong "three!"))
   `((list . ,(lambda (tag body)
                (cons 'ol (map (lambda (x) (list 'li x)) body))))