Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (use-modules (srfi srfi-1) (ice-9 match) (sxml simple))
- (define top-id "top-id")
- (define (print-enum id nicks)
- (display
- (string-append
- " <enum id=\"" top-id "." id "-enum\">\n"))
- (fold
- (lambda (nick idx)
- (format #t
- " <value nick=\"~a\" value=\"~d\"/>\n"
- nick idx)
- (1+ idx))
- 0
- nicks)
- (display " </enum>\n"))
- (define (print-enum1 id nicks)
- (let* ((top-id (string-append top-id "." id "-enum"))
- (nicks (let lp ((nicks nicks) (idx 0) (res '()))
- (match nicks
- (() (reverse res))
- ((nick . rest) (lp rest (1+ idx)
- (cons `(value (@ (nick ,nick)
- (value ,idx)))
- res))))))
- (sxml `(enum (@ (id ,top-id)) ,nicks)))
- (display (sxml->xml sxml))))
- (newline)
- (print-enum "a" '("a" "b" "c"))
- (print-enum1 "a" '("a" "b" "c"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement