Here's my plain-old Icon solution:

procedure main(a)
    src := ""
    while src ||:= reads(,1000000)

    usage := table()
    every usage[!a] := 0

    r := ""
    src ? {
        while r ||:= tab(upto('<')) do
            r ||:= (tag(usage) | move(1))
        write(r || tab(0))
        }
end
procedure tag(u)
    if r := ="</" || (w := =key(u)) || =">" & u[w] -:= 1 then
        return if u[w] = 0 then r else ""
    else if r :=  ="<" || (w := =key(u)) || =">" & u[w] +:= 1 then
        return if u[w] = 1 then r else ""
end

I haven't looked at the other solutions but I did engage my son to tell me
about the length of mine wrt. the others.

There must be a concise way to unify the opening/closing tag handling, but
I just can't see it.

A multiset would be handy for nonnumerically counting the nesting level.

|---------------------------------|
|       William H. Mitchell       |
|  Mitchell Software Engineering  |
|          www.mse.com            |
| Consulting/Development/Training |
|   OOA/D -- Java -- C++ -- Icon  |
|                                 |
|   [EMAIL PROTECTED]    520-577-6431   |
|---------------------------------|



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to