goal_expansion
Jonathon Doran <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[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