Skip to content

Instantly share code, notes, and snippets.

@horpto
Created November 24, 2016 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horpto/d870dcd0c522117bcc3e5cbd6dd4f972 to your computer and use it in GitHub Desktop.
Save horpto/d870dcd0c522117bcc3e5cbd6dd4f972 to your computer and use it in GitHub Desktop.
PREDICATES
nondetermclear_string(string, string)
CLAUSES
clear_string("", "").
clear_string(Str, Res) :-
frontstr(1, Str, Fchar, Rest),
Fchar = " ", !,
clear_string(Rest, Res)
.
clear_string(Str, Res) :- !,
frontstr(1, Str, Fchar, Rest),
clear_string(Rest, Tail),
concat(Fchar, Tail, Res)
.
goal
clear_string("hell oo lss ", R), write(R).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment