Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!news2.near.net!MathWorks.Com!news.kei.com!eff!news.duke.edu!news-feed-1.peachnet.edu!gatech!howland.reston.ans.net!swrinde!sgiblab!pacbell.com!uop!csus.edu!netcom.com!mikelo
From: mikelo@netcom.com (mike lottridge)
Subject: SProlog question
Message-ID: <mikeloCwK4xv.Hyv@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
Date: Fri, 23 Sep 1994 00:49:07 GMT
Lines: 23

I'd like to be able to read an expression in prolog, then extract the
variables from the expression, get their values, then process the
expression. I'm not sure how to do this in Small Prolog.

For example, suppose I have a clause called "eval", which can evaluate some
algrebraic expression like this: 

  eval( (X "+" (Y "*" Z)), Result)
I'd like to get the expression from the user, then get any needed variable
values, then call evaulate, like this:

read (Exp)
{do a read for every variable in Exp}
eval(Exp, R)

If I read (X "+" Y) for exp, then do a (read X) (read Y)(eval Exp,R), I see
when I do a trace, that eval is passed Exp without the variables X and Y
bound to the values obtained during the read. I'm probably doing something
basically wrong, since I'm new to Prolog. Any help would be appreciated!
-- 
Mike Lottridge
Applications Engineering, Lattice Semiconductor
email: mikelo@netcom.com office phone: (800)327-8425
