users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding a variable to the "output" of a predicate


From: Vic Bancroft
Subject: Re: Binding a variable to the "output" of a predicate
Date: Fri, 25 Oct 2002 08:33:27 -0400 (EDT)

On Thu, 24 Oct 2002, Andy Schmidgall wrote:

> I'm attempting to translate some prolog code fragments from a different
> version of prolog into gprolog, and I was wondering if it's possible to bind
> a variable to the "output" of a predicate. I suppose it would be like
> redirecting the output to a variable rather than standard out.

Is there something that keeps you from using ther infix operator to unify terms,
as per section 7.2.1 ?

> I'm wondering if there's a way to get the results into a variable. The code
> fragment I'm translating from used a construct like this:

Section 7.10 on streams might be helpful, however it sounds like you are really
interested in the Constant Term Streams discussed in 7.11.

  Constant term streams allow the user to consider a constant term (atom,
  character list or character code list) as a source/sink by associating to
  them a stream. Reading from a constant term stream will deliver the
  characters of the constant term as if they had been read from a standard
  file. Characters written on a constant term stream are stored to form the
  final constant term when the stream is closed. 
  
If this is close to what you want, section 7.14 has some convenience predicates.

> write_output(X) ~> Y
> 
> (The operator is tilde-greater-than)

In what flavor of prolog was that an operator ?

more,
l8r,

------------------------------------------------------------------- 
Victor Bancroft, Principal Engineer, Zvolve Systems [v]770.551.4505 
1050 Crown Pointe Pkwy, Suite 300, Atlanta GA 30338 [f]770.551.4509 
Fellow, Artificial Intelligence Center              [v]706.542-0358 
Athens, Georgia  30602, U.S.A           http://ai.uga.edu/~bancroft 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]