"Pablo Barenbaum" foones@gmail.com writes:
I post a partial solution to the off-side-reader quiz. I say "partial" because, even though it reads in off-side mode, I'm not sure if it works as it is supposed in every case, i.e.:
- what about blank lines?
ignore them.
- what about comments?
interesting question. i'd say that you can just ignore both ; and #| style comments. handling them makes for a good bonus question.
- the !# is supposed to be alone in a single line?
yes. i assumed, though did not explicitly state, that the opening #! and closing !# would be be themselves an a single line.
I'm afraid I tend overuse format and loop.
:)
It is also possibly very inefficient: it generates a new string with the "correct", inherent, parens made explicit, then reads it.
that sounds like a perfectly good technique to me, don't worry about the efficency of it.