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...
No2 is ...
%% program %%%
replast([], _, []).
replast([L], X, [X]) :- !.
replast([L1|LS], X, [L1|M]) :- replast(LS, X, M).
%%% sample %%%
?- replast([10, 20, 30], 90, M).
M = [10,20,90] ;
no
?- replast([10], 90, M).
M = [90] ;
no
?- replast([], 90, M).
M = '[]' ;
no
?- replast([10, 20...
Hello. Is this suitable as a reply?
%%% show lists
?- listing.
data([hello,world]).
data([hello,london]).
data([good,morning,tokyo]).
yes
%%% enum all lists
?- data(X), write(X).
[hello,world]
X = [hello,world] ;
[hello,london]
X = [hello,london] ;
[good,morning,tokyo]
X =...
Hello.
I think that there are the following two methods.
1. restricting the depth of search
2. check the way along which it already passed
*** program ***
% 1 2 3
% +---+---+---+
% 1 | S |
% +---+ + +
% 2 | |
% + +---+---+
% 3 | / G |
%...
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.