Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Unifying with partially ground terms without unifying with
Robert Oschler wrote:
>
> 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?

if you want to check if two variables unify without unification been
made
try this

\+ \+ X = Y

double negation (seen in nlp in prolog by shieber and perreira)


Have fun


Djamé

Report this thread to moderator Post Follow-up to this message
Old Post
Djame Seddah
10-22-04 01:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Prolog archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:55 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.