Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
|
---|
Replies are listed 'Best First'. | |
---|---|
Sibling - Make Nicer Post!
by George_Sherston (Vicar) on Oct 02, 2001 at 14:38 UTC | |
If you want answers, you're posting in the right place. I think most monks are fully seized of the dictum that it is more blessed to give than to receive, and there is a real zest for helping out round here, as I know very well from happy experience. But it's only polite, as well as wise, to make a little effort with one's question. Then a wealth of knowledge awaits you. And sooner or later you'll find a question you can answer, which will be even more fun. Perlmonks really is a community - treat it that way and it'll work wonders for you. </PREACH> § George Sherston | [reply] |
Re: finite automata
by clemburg (Curate) on Oct 02, 2001 at 16:05 UTC | |
Sorry, I could not resist ... fsm.pl:
fsm.config:
Christian Lemburg | [reply] [d/l] [select] |
Re: finite automata
by pjf (Curate) on Oct 02, 2001 at 14:23 UTC | |
You mentioned finite automata in your subject line, though. Am I missing something else here? ;)
Cheers,
| [reply] [d/l] |
Re: finite automata
by doc (Scribe) on Oct 02, 2001 at 15:43 UTC | |
This will get you started:
doc print(s<>ecode?scalar reverse :p) | [reply] [d/l] |
by davorg (Chancellor) on Oct 02, 2001 at 16:10 UTC | |
I may, of course, be misunderstanding the problem, but it sounds to me like you're not given a complete listing of the language dictionary - simply a set of rules that valid words must obey. In that case pjf's regex-based solution is far more efficient (assuming, of course, that you can represent each of the rules as a regex). --<http://www.dave.org.uk> "The first rule of Perl club is you don't talk about Perl club." | [reply] |
by doc (Scribe) on Oct 02, 2001 at 22:36 UTC | |
As you note it does rather depend on what the problem is. Depending on the situation and the complexity of the language a pre-generated hash lookup table will be potentially much faster than a regex solution. Consider a simple alphabet that may only contain words in the form: aa ab ac ad .... az. Including the overhead of generating the hash lookup table the hash method is much faster than a comparable regex method as well as being far more flexible.
doc print(s??cod??scalar reverse :p) | [reply] [d/l] |
Re: finite automata
by demerphq (Chancellor) on Oct 02, 2001 at 17:48 UTC | |
Yves | [reply] |