Talk:Tokenize a string with escaping

Revision as of 01:51, 12 January 2017 by rosettacode>Samsergey (Added the post: The alternative Haskell solution needs attention)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The alternative Haskell solution needs attention

Unfortunately, the alternative Haskell solution, given by @Hout doesn't show the strength of Haskell. The alternative solution is very inefficient in case of big lists, due to a pattern list ++ [element]. It ruins the effect of foldl or foldl'.

It is possible to make this solution better by using difference lists with O(1) snoc operator, but then it would require toList . map toList instead of reverse . map reverse as postprocessing. Another workaround would be to replace ++ by : and perform reversion, but in this case the alternative solution will become just a paraphrase of a DFT solution with less modular logic.

After all, it is a sort of parsing problem, so the most natural solution would use some parsing technique (DFT, for example). I would be happy to see an alternative solution using any of parsing libraries, or conduits/pipes so that it could handle real-world text-based cases and demonstrate everyday practice.

I recommend to remove the solution.

Return to "Tokenize a string with escaping" page.