On Fri, Feb 18, 2011 at 12:02 PM, Alexander Mikhailov <avm...@yahoo.com>wrote:
> What does it mean? Just a task, which is not very good for J? Or some > libraries are practically required for tasks like this? Or I'm missing some > solution? > Typically, you would read input in blocks, and when the blocks became too small for efficient processing you would read another block. This is how stdio works in C, and this works well enough in J. If you have a frequently used character which cannot be a part of a token (for example, a line end character), it's reasonable to use the absence of any characters preceding this delimiter as a signal that it's time to read another block. Also, for text parsing, and program driven data fetching, I would be inclined to use a while loop rather than ^: Buffering tend to involve hetrogenous state, and is often best expressed using references, where ^: may terminate early when you have state in references, and is best when you have homogeneous state. Meanwhile, sequential machine is not perfect (for example, I keep wanting it to give me a list of states at each character, but the only way to do that requires function code f=5), but it it's a pretty good tokenizer, and simpler to understand than lex, in my opinion. -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm