Total newb for Prolog. It disappoints me a little. My "solution" is below - I'm trying to make Prolog procedural ...
This will remove the spaces or add a space after the decimal point, if necessary, that is, until a period occurs:
squish:-get0(C),put(C),rest(C). rest(46):-!. rest(32):-get(C),put(C),rest(C). rest(44):-put(32), get(C), put(C), rest(C). rest(Letter):-squish.
PURPOSE: I am wondering how to remove spaces before the comma.
The following works, but it is so wrong on so many levels, especially in "exit"!
squish:- get0(C), get0(D), iteratesquish(C,D). iteratesquish(C,D):- squishing(C,D), get0(E), iteratesquish(D,E). squishing(46,X):-put(46),write('end.'),!,exit. squishing(32,32):-!. squishing(32,44):-!. squishing(32,X):-put(32),!. squishing(44,32):-put(44),!. squishing(44,44):-put(44), put(32),!. squishing(44,46):-put(44), put(32),!. squishing(44,X):-put(44), put(32),!. squishing(X,32):-put(X),!. squishing(X,44):-put(X),!. squishing(X,46):-put(X),!. squishing(X,Y):-put(X),!.