Hello.
How about using retract and assert.
?- state(jalisco,jal,guadalajara,X).
X = 6322002 ;
no
?- retractall(state(jalisco,jal,guadalajara,_)).
yes
?- assertz(state(jalisco,jal,guadalajara,6950850)).
yes
?- state(jalisco,jal,guadalajara,X).
X = 6950850 ;
no
How is it now?
?- hello(X).
no
?- asserta(hello(world)).
yes
?- asserta(hello(japan)).
yes
?- hello(X).
X = japan ;
X = world ;
no
?- retract(hello(world)).
yes
?- hello(X).
X = japan ;
no
It may solve by this program.
is_between(X, Y, N) :-
X - 1 < Y,
N is X.
is_between(X, Y, N) :-
X - 1 < Y,
is_between(X + 1, Y, N).
example:
?- is_between(3, 11, 1).
no
?- is_between(3, 11, 3).
yes
?- is_between(3, 11, 7).
yes
?- is_between(3, 11, 11).
yes
?- is_between(3, 11...
Hello.
I can't understand what you want to do correctly, but I guess...
*** program ***
minmax(L, Min, Max) :- minlist(L, Min), maxlist(L, Max).
*** test ***
?- minmax([1, 2, 3], Min, Max).
Min = 1
Max = 3 ;
no
?- minmax([9], Min, Max).
Min = 9
Max = 9 ;
no
?- minmax([7, 8, 6], Min, Max)...
Hello.
The SWI has "string_to_list" predicate.
string_to_list('123 abc 456', X).
X = [49, 50, 51, 32, 97, 98, 99, 32, 52|...]
It can also convert char-list to string.
string_to_list(X, [49, 50, 51]).
X = '123'
So, how about this idea? -> (1) convert string to char-list...
Hello.
When using Amzi, it describes as follows.
?- string_split($123 abc 456$, $ $, S).
S = [$123$,$abc$,$456$] ;
no
?- string_split($123 abc 456$, $ $, [S1, S2, S3]).
S1 = $123$
S2 = $abc$
S3 = $456$ ;
no
Probably, it is dependent on a compiler.
"string_split" is the predicate...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.