| Paste number 30310: | xml-each |
| Pasted by: | LittleDan |
| When: | 3 years, 3 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+NDY |
| Channel: | #concatenative |
| Paste contents: |
! this would go in xml/utilities.factor
GENERIC: (xml-each) ( quot tag -- )
M: tag (xml-each)
[ tag-children [ (xml-each) ] each-with ] 2keep
swap call ;
M: object (xml-each)
swap call ;
M: xml-doc (xml-each)
delegate (xml-each) ;
: xml-each ( tag quot -- ) swap (xml-each) ;
Annotations for this paste:
| Annotation number 1: | xml-map |
| Pasted by: | LittleDan |
| When: | 3 years, 3 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+NDY/1 |
| Paste contents: |
: with-delegate ( object quot -- object )
over clone >r >r delegate r> call r>
[ set-delegate ] keep ;
GENERIC: (xml-map) ( quot tag -- tag )
M: tag (xml-map)
[ tag-children [ (xml-map) ] map-with ] 2keep
rot >r clone swap call r> over set-tag-children ;
M: object (xml-map)
swap call ;
M: xml-doc (xml-map)
[ (xml-map) ] with-delegate ;
: xml-map ( tag quot -- tag ) swap (xml-map) ;