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 Mike Lewis 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: *

  1. joel76

    prolog program predicate

    'or' is achieved with a semicolon ';'. If I understand your question 'to have a failure' you can use \+ wich is the negation \+a. gives 'false'
  2. joel76

    prolog program predicate

    You should say "a succeeds only if b, c and d (so e) succeed". Since b, c and e are facts, a succeeds. Yes, every letter in this example can be a goal.
  3. joel76

    prolog program predicate

    Notice that b, c and e are called "facts
  4. joel76

    prolog program predicate

    That's correct but you must use lowercase letters : a :- b, c, d. b. c. d :- e. e.
  5. joel76

    prolog issue

    You must have facts, e.g. percentage of troubles when there is a cranky husband or a demanding wife. These facts may be converted in rules, so you have to search for "expert system".
  6. joel76

    prolog sublist

    Your question is not very clear ! Can you give an example of a query with the input and the expected result. What have you tried ?
  7. joel76

    DFS searching in Prolog

    I can't edit my posts so, I give you another way to count nodes in DFS without assert/retract : dfs_search_node(Tree,Node, N) :- dfs_search_node_(Tree,Node, 1, _, N). dfs_search_node_(tree(Node, _, _), Node, FN, _, FN) :- !. dfs_search_node_(tree(_, L, R), Node, CN, _TN, FN) :- CN1 is CN +...
  8. joel76

    DFS searching in Prolog

    It's easyer than bfs : bfs_search_node(Tree,Node, N) :- bfs_search_node_([Tree],Node, 1, N). bfs_search_node_([tree(Node, _, _) | _T], Node, FN, FN) :- !. bfs_search_node_([tree(_, L, R) | T], Node, CN, FN) :- CN1 is CN + 1, append(T, [L, R], T1), bfs_search_node_(T1, Node, CN1, FN).
  9. joel76

    How: member-x in a list is also member-y

    Is is possible that sameas(S1, S2) and sameas(S1, S3) implies sameas(S2,S3) ?
  10. joel76

    DFS searching in Prolog

    This sample can be usefull. :- dynamic fact/1. example :- test(asserta), test(assertz). test(Pred) :- format('~nWith ~w~n~n', [Pred]), Call_1 =.. [Pred, fact(1)], Call_2 =.. [Pred, fact(2)], Call_3 =.. [Pred, fact(3)], maplist(call, [Call_1, Call_2, Call_3]), list...
  11. joel76

    How: member-x in a list is also member-y

    That's not very clear ! What do you mean by member1 is also member2 ? Can you give an example with a list !
  12. joel76

    DFS searching in Prolog

    Thanks !
  13. joel76

    DFS searching in Prolog

    If I understand what you mean, for 6 it should 10 : 6 is not 1 : step 1 then I search in left tree 6 is not 2 : step 2 I search in left tree 6 is not 3 : step 3 I search in left tree tree empty : step 4 I search in right tree tree empty : step 5 ..... According to this scheme I propose : :-...
  14. joel76

    DFS searching in Prolog

    You can try search_node(tree(Node, _, _), Node, 0) :- !. search_node(tree(_, L, R), Node, N) :- ( search_node(L, Node, N1); search_node(R, Node, N1)), N is N1+1.
  15. joel76

    Functions Implementation on Prolog

    You can look at this page http://www.swi-prolog.org/git/pl.git/blob/HEAD:/boot/init.pl
  16. joel76

    prolog noob question.

    With SWI-Prolog, type gtrace to understand what happend. You will notice that you don't test Exp, is it always positive ? Can it be negative ?
  17. joel76

    Prolog "little" issue

    Well here is my code, works with SWI-Prolog child_of(name1,name0). child_of(name2,name1). child_of(name3,name2). descendent(X,Y) :- child_of(X,Y). descendent(X,Y) :- child_of(Z,Y), descendent(X,Z). If I use descendent(X,Y) :- descendent(X,Z), child_of(Z,Y). at the query descendent(name1...
  18. joel76

    Prolog "little" issue

    The design for descendent/2, is almost good : try descendent(name1, name0) and after the answer true type ";" instead of Enter, you will enter an infinite loop ! After having fixed the bug, try the same design for descendent/3.
  19. joel76

    Einsteins problem in prolog

    I wrote exactly that, and I get the desired solution. What do you get ? false ? Be ware of typo.
  20. joel76

    Einsteins problem in prolog

    Sorry, I made a mistake, I wanted to say disjunction and I wrote conjunction.

Part and Inventory Search

Back
Top