Re: goal_expansion
Carlo Capelli <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CABty9wxORQWVUQ2DzxSGTRH+q+UtvaYsbn4ny0RD3nda-k+JoQ@mail.gmail.com> |
Hi Jonathon From my self-learner experience (mainly lifter<https://github.com/CapelliC/prolog-snippets/blob/master/lifter.pl>) I have an hint - maybe useful only if you use XPCE IDE - or anything similar... I think you'll need to place near bottom of source a condition :- multifile user:goal_expansion/2. user:goal_expansion(X, Y) :- \+ current_prolog_flag(xref, true), ... your_code Indeed, I experienced IDE freezing with a 'cross-referencing buffers' message before I discovered that trick - in library(clpfd), if I recall rightly. bye Carlo 2014-02-09 1:46 GMT+01:00 Jonathon Doran <[email protected]>: > I would very much like to see a simple example of the use of > goal_expansion. > > I have a large program, and I would like to make a series of changes. I > see that I am following the same pattern each time, and if I were writing > in another language I would consider creating a macro. > > This may be the wrong technique to use in Prolog, but I'm curious if it > would be possible. > > For example: A list is passed to a predicate, and the list is checked for > an optional member (may or may not be there). If the member is in the > list, we use it. If not, a default value is used. > > Writing the code by hand I might do: > > ( > \+ member(color:Color, List) -> > random_color(Color) > ; > true > ), > > > I am wondering if I can clean that up to something more readable via > goal expansion. > > (This may be a dumb way to go about things, but I would rather not rewrite > a huge chunk of existing code) > > Thanks, > Jonathon Doran > _______________________________________________ > SWI-Prolog mailing list > [email protected] > https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog > -------------- next part -------------- HTML attachment scrubbed and removed