From pm at hutnick.com Tue Jul 6 10:54:59 2004 From: pm at hutnick.com (Peter Hutnick) Date: Mon Aug 2 21:25:49 2004 Subject: [Boulder.pm] Queue (FIFO) Message-ID: <40EACB53.8070607@hutnick.com> You may remember that I was writing a script to convert LaTeX to HTML. You may also remember that I was using a gaggle of regex replacements to do it. You probably thought that it was a bad idea. And you were probably right. So now I am thinking on rewriting it. My current thinking is to tokenize it into LaTeX tags and blocks of text within those tags. I have to face some difficult realities of LaTeX syntax, but I am confident that I can overcome the problems. Anyway, I want to push those tokens into a queue (or FIFO, as you like). Then "pop" them back off, do some magic, and write them to my HTML output file. Of course, push and pop won't do this, as I understand it. I've seen examples using push and unshift. Is this the idiomatic way to do it? I really don't need a bad-assed OO data structure to handle this, but I want to write something that isn't write-only ;-) Thanks in advance for any and all replies. This is a great, if quiet, list! -Peter From keanansmith at techie.com Thu Jul 8 19:16:37 2004 From: keanansmith at techie.com (Keanan Smith) Date: Mon Aug 2 21:25:49 2004 Subject: [Boulder.pm] Queue (FIFO) Message-ID: <20040709001637.C08E616402D@ws1-4.us4.outblaze.com> Not *quite*, you can use (push and shift) or (unshift and pop) to get FIFO style behaviour If this is your list: 1 2 3 4 5 6 7 8 push puts a value after the 8, pop gets the 8 and removes it from the list, shift gets the 1 and removes it from the list (moving everything up a slot), and unshift puts a new value before the 1 and shoves everything down. a QUEUE (a FIFO list) puts things in on one side of the list and pulls things off the other side. Which pair to use is entirely up to you, it's just a question of which end you want to call "in" and which end you want to call "out" (Personally I like push and shift, just because I think that unshift doesn't roll off the tongue very well, but that's me. :) ----- Original Message ----- From: Peter Hutnick Date: Tue, 06 Jul 2004 09:54:59 -0600 To: boulder-pm@mail.pm.org Subject: [Boulder.pm] Queue (FIFO) > You may remember that I was writing a script to convert LaTeX to HTML. > You may also remember that I was using a gaggle of regex replacements to > do it. You probably thought that it was a bad idea. And you were > probably right. > > So now I am thinking on rewriting it. My current thinking is to > tokenize it into LaTeX tags and blocks of text within those tags. I > have to face some difficult realities of LaTeX syntax, but I am > confident that I can overcome the problems. > > Anyway, I want to push those tokens into a queue (or FIFO, as you like). > Then "pop" them back off, do some magic, and write them to my HTML > output file. Of course, push and pop won't do this, as I understand it. > > I've seen examples using push and unshift. Is this the idiomatic way to > do it? I really don't need a bad-assed OO data structure to handle > this, but I want to write something that isn't write-only ;-) > > Thanks in advance for any and all replies. This is a great, if quiet, list! > > -Peter > _______________________________________________ > Boulder-pm mailing list > Boulder-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/boulder-pm -- ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm