Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: pimi
  • Order by date
  1. pimi

    how can I change the knowledge base??

    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
  2. pimi

    Get keyword from a list

    Hello. I do not understand well. Please explain a little in more detail.
  3. pimi

    how can I see multiple answears

    Hello. If ent(6) is changed into ent(State, Stt), what will happen?
  4. pimi

    Place variables in a list and rank them as output results

    Hello. How is this program? I am using Amzi Prolog. test :- write('Enter M1: '), read(M1), write('Enter M2: '), read(M2), write('Enter M3: '), read(M3), write('Enter M4: '), read(M4), write('Enter M5: '), read(M5), sort([M1, M2, M3, M4, M5], X), myrev(X, R)...
  5. pimi

    Explain me How Prolog Learn? Please¡

    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
  6. pimi

    Variables type in Prolog

    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...
  7. pimi

    Disjunctive

    Hello. describe it in parallel ??? *** program *** child(X) :- boy(X). child(X) :- girl(X). *** assert *** ?- assert(boy(john)). yes ?- assert(girl(mary)). yes *** question *** ?- boy(john). yes ?- child(john). yes ?- child(X). X = john ; X = mary ;
  8. pimi

    Hard Prolog Problem - Permutation of Equations

    Hello. This is an incomplete program. Please change post-fix notation to in-fix notation. %%% solve([3, 2, 1], Ans) -> %%% [3] = [2, 1, +]; %%% [3, 2, -] = [1]. solve(N, Ans) :- split(N, L, R), pattern(L, 0, [], LPattern), pattern(R, 0, [], RPattern), calc(LPattern, [], LAns)...
  9. pimi

    Prolog help with min,max program

    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)...
  10. pimi

    List Search

    Hello. I cannot understand correctly what you want to do, but I guess... *** program *** samehead([], _). samehead([X1|Xs], [X1|Ys]) :- samehead(Xs, Ys). exist(X, Y) :- samehead(X, Y), !. exist(X, [_|Y]) :- exist(X, Y). search(X, [Y|_], 1) :- exist(X, Y), !. search(X, [_|Ys], N) :- search(X...
  11. pimi

    split a string

    Hello. The SWI has &quot;string_to_list&quot; 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...
  12. pimi

    split a string

    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. &quot;string_split&quot; is the predicate...
  13. pimi

    bagof

    Hello. How about using &quot;findall&quot; instead of &quot;bagof&quot; ?
  14. pimi

    Define the functions in prolog

    And No.3 is ... exchfal([], []). exchfal([L1|LS], [W1|W2]) :- lastelem([L1|LS], W1), replast(LS, L1, W2).
  15. pimi

    Help! Problem with sorting an list...

    Hello. This program enumerates all patterns. Please add restriction to this program. ins(X, L, [X|L]). ins(X, [L1|LT], [L1|RT]) :- ins(X, LT, RT). perm([], []). perm([L1|LT], R) :- perm(LT, W), ins(L1, W, R). main(A, B, C, D, E, F, G) :- perm([1, 2, 3, 4, 5, 6, 7], [A, B, C, D, E, F, G])...
  16. pimi

    Define the functions in prolog

    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...
  17. pimi

    Define the functions in prolog

    Hello. No.1 is easy. lastelem([X], X). lastelem([_|R], X) :- lastelem(R, X).
  18. pimi

    lists

    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 =...
  19. pimi

    problem with a recursive definition

    f(a, b, c, f(x, y). ?
  20. pimi

    Iterative deepening search - Help!

    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 | %...

Part and Inventory Search

Back
Top