Unifying with partially ground terms without unifying with completely unground terms?

From: Robert Oschler (no-mail-please_at_nospam.com)
Date: 10/21/04

  • Next message: Bart Demoen: "Re: Unifying with partially ground terms without unifying with completely unground terms?"
    Date: Thu, 21 Oct 2004 12:27:12 -0400
    
    

    I have a program where I want to take certain action on various list items,
    if certain elements match a certain predicate name only.

    For example, given the list:

    [Var1, op(SubVar1), Var2, ...]

    I have a predicate that 'walks' the list and only manipulates the term if it
    is a op() predicate element. To do this I wrote the following predicate:

    % Determine if an element is an op() predicate without unifying with
    unground variables.
    is_op_term(OpTerm, Innards):-
     OpTerm =.. [X | Args],
     ground(X),
     X = op,
     Innards =.. Args,
     !.

    This works fine but it I wonder if there is a more elegant way to do this.
    The problem with attempting to handle the op() predicate elements with a
    clause like:

    do_op([op(X) | T]):- % etc.

    Is that the head of the list in the clause will unify with completely
    unground variables, which is what I don't want. I only want grounded or
    partially grounded variables that are currently instantiated to an op()
    term.

    I tried using 'not', hoping to test the element without unifying with it,
    but ended up with a control error:

    do_op([H | T]):-
        not (H = op(X)),
        !,
        ... % etc.

    So what's a better way to do this?

    Thanks,
    Robert.

    -- 
    Robert Oschler
    http://www.robotsrule.com/phpBB2/
    Robot & Android Discussion Forum
    

  • Next message: Bart Demoen: "Re: Unifying with partially ground terms without unifying with completely unground terms?"

    Relevant Pages

    • Re: Unifying with partially ground terms without unifying with completely unground terms?
      ... > if certain elements match a certain predicate name only. ... > unground variables, which is what I don't want. ... > partially grounded variables that are currently instantiated to an op ... if you want to check if two variables unify without unification been ...
      (comp.lang.prolog)
    • Re: Unifying with partially ground terms without unifying with completely unground terms?
      ... > % Determine if an element is an oppredicate without unifying with ... > unground variables. ... > Innards =.. ...
      (comp.lang.prolog)
    • Re: Sense lining--2nd try
      ... you have to break a clause, keep the subject and predicate together. ... I've never taken a speed reading course. ... I've worked on a lot of PowerPoint presentations, because I was required to do so for a job. ...
      (comp.fonts)
    • Re: Sublists question
      ... Since any of the variables can be s, this clause is certainly true. ... Here is an alternative predicate that does not have that problem. ... What Prolog are you using? ... Anyway, with the new sublist/2 predicate, the query, langford, ...
      (comp.lang.prolog)
    • case of predicates
      ... Quite often a COND is simply a series of predicates all ... finding the first predicate that is true of the original value. ... (if (eq t (car clause)) ... `((,(car clause),var) ...
      (comp.lang.lisp)