Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For those that don't know, Prolog allows of parsing in very nice ways and very easily using Domain Clause Grammar.

parse(Output)--> [Input], {member(Input, [ab, cd]), atom_codes(Input, Output)}.

test(In):- phrase(parse(L), [In]), writeln(L).

?- test(ab). [97,98] true .

?- test(cd). [99,100] true.

?- test(xy). false.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: