What is the best way to normalize whitespace characters (space, newline, tab) in a Prolog atom, e.g. in SWI-Prolog. I.e. I would like to have a rule:
normalize_space_in_atom(+Atom1, -Atom2)
such that Atom2
SWI Prolog provides normalize_space/2, and so you could define your predicate as follows:
normalize_space_in_atom(A1,A2) :- normalize_space(atom(A2),A1).
I've tried this out with SWI Prolog 5.7.5 and it appears to work. You could add more error handling if you wish.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With