This is a very long question ... I am new and joined, so please don\'t attack me. Apologies for my bad communications in English. I have some defintions:
An HTML(H) is on
You have the right idea, but still - there are three main issues with your proposed solution:
This will work, take a careful look at the things that changed:
(define (html->string html)
(cond [(empty? html) ""]
[(string? html) html]
[(not (symbol? (first html)))
(html->string (first html))]
[else (string-append
"<" (symbol->string (first html)) ">"
(change-tag (rest html))
"</" (symbol->string (first html)) ">")]))
(define (change-tag lst)
(cond [(empty? lst) ""]
[else (string-append
(html->string (first lst))
(html->string (rest lst)))]))
It works as expected:
(define html
(list 'html
(list 'head
(list 'title "Hi"))
(list 'body
(list 'h1 "Welcome")
"Text")))
(html->string html)
=> "<html><head><title>Hi</title></head><body><h1>Welcome</h1>Text</body></html>"