Word break problem: Difference between revisions

→‎Functional Python: Removed latest tendentious intervention. Pythonic Python is a good dialect of the language, but not the language itself, and is deliberately not optimised for functional programming. Time for you to abandon this silly campaign.
(→‎Functional: improve.)
(→‎Functional Python: Removed latest tendentious intervention. Pythonic Python is a good dialect of the language, but not the language itself, and is deliberately not optimised for functional programming. Time for you to abandon this silly campaign.)
Line 745:
=={{header|Python}}==
===Functional===
 
{{improve|Python|Reads like machine translated Haskell rather than idiomatic Python}}
The '''tokenTrees''' function recursively builds a tree of possible token sequences, using a list monad ('''concatMap''' with a function which returns its result wrapped in a list – an empty list where a parse has failed) to discard all branches which lead to dead ends. This allows us to return more than one possible word-break parse for a given lexicon and input string. (Searches for 'monadic parsing in Python' will yield references to more sophisticated uses of this general approach).
 
9,659

edits