I'm posting this to both groups because, while the solution
I have is Unicon specific, I think it makes a fun exercise
for the pure 'Iconers' as well.
I haven't posted an Icon 'challenge' for a while, so here's
a new one - it's not particularly difficult, but does take
some thought.
There was a discussion recently on the SNOBOL4 mailing list
(gee, I've just tied three generations together, how cute...)
about how to write a program to 'flatten' tags.
The original posting was:
--------------------------
This is what I have:
<x>This is item 1. <x>This is item 2.</x> This</x> is <x>item
<x>3</x>.</x>
This is what I need:
<x>This is item 1. This is item 2. This</x> is <x>item 3.</x>
I need to removed nested <x></x> tag pairs.
--------------------------
Ok - write a Unicon or Icon program to do this.
Some additional notes:
(1) You may assume that you are only interested in a single tag.
You can use "<x>" and "</x>" as the start end markers for
that tag, but it would be a better program if it accepted
the tag as a command-line argument. (A separate challenge
would be to handle a set of tags instead of just one, but
please do that separately if you're interested in it!)
(2) You may assume that the tags are "well-formed": no special
tag format, just "<"||tag||">" and "</"||tag||">", and
no tag marker is split across a line boundary.
(3) The start and its matching end marker may be on different
lines, separated by an arbitrary number of intervening lines.
(4) The input is *not* xml, In particular, the following is
a perfectly valid input line:
<x>This is a <k>relation <x>a<x<y<z> isn't it</x></z>?
I'll post my Unicon solution in a few days.
-Steve
--
Steve Wampler -- [EMAIL PROTECTED]
The gods that smiled on your birth are now laughing out loud.
-------------------------------------------------------
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