Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
replace( T1, S1, S2, T2 ) :-
segment( S1, Pre, T1, Post ),
append( S2, Post, S2_plus_Post ),
append( Pre, S2_plus_Post, T2 ).
segment( List, [], [], List ) :- !.
segment( [H|T_], [], [H|T], Post ) :-
segment( T_, [], T, Post ), !.
segment( [H|T_], [H|U], Seg, Post ) :-
segment( T_, U, Seg, Post ).
start :-
String = "hi(pippo)",
replace("(", String, " ", NewString1),
replace("p", NewString1, "c", ResultString),
atom_chars(Result, ResultString),
write(Result).
replace(LstOld, LstNew, S1, S2 ) :-
maplist(replace_word(LstOld, LstNew), S1, S2).
replace_word(LstOld, LstNew, W1, W2) :-
nth0(Ind, LstOld, [W1]),
nth0(Ind, LstNew, [W2]).
replace_word(_LstOld, _LstNew, W, W).
remove(LstWord, S1, S2 ) :-
exclude(remove_word(LstWord), S1, S2).
remove_word(LstWord, Word) :-
member([Word], LstWord).
start :-
String = "hi(pippo)",
replace(["(", "p"], [" ", "c"], String, ResultString1),
remove([")", ":", "!"], ResultString1, ResultString2),
atom_chars(Result, ResultString2),
write(Result).
test :-
call_predicate("string to test"), ...
read_string :-
read(Atom),
atom_chars(Atom, AtomAsString),
writef("%s", [AtomAsString]).
test :-
hi(pippo),
hi(george).
:-dynamic(hi/1).
test :-
hi(pippo),
hi(george).
write_result(Term) :-
[COLOR=red]
term_to_atom(Term, Atom),
atom_codes(Atom, String),
[/color]
replace("(", String, " ", NewString1),
replace(")", NewString1, ".", ResultString),
atom_codes(Result, ResultString),
write(Result).
write_body(N,(First,Rest)) :-
tab(N),
write_result(First),
nl,
write_body(N,Rest).
write_body(N,Last) :-
tab(N),
write_result(Last),
nl.
how(Goal) :-
clause(Goal,Body),
write_body(4,Body).