Did you know ... | Search Documentation: |

Predicate function_expansion/3 |

- user:
**function_expansion**`(+Term, -Replacement, -Guard)`is**semidet** -
Like term_expansion/2, function_expansion/3 provides for macro expansion of Prolog source code. In this case, by expanding

`Term`which is nested inside a parent term.`Term`is replaced with`Replacement`.`Guard`is placed as a conjunction before the parent term.`Guard`typically binds`Replacement`in some useful fashion.For example, a function macro which doubles its argument might expand this

user:function_expansion(double(X), Y, Y is 2*X). main :- V = 9, format('~p times 2 is ~p~n', [V, double(V)]).

into this == main :- V = 9, A is 2*V, format('~p times 2 is ~p~n', [V, A]). == Mathematical constants might be implemented like == user:function_expansion(pi, 3.14159, true). ==

- user:
**function_expansion**`(+Term, -Replacement, -Guard)`is**semidet** -
Like term_expansion/2, function_expansion/3 provides for macro expansion of Prolog source code. In this case, by expanding

`Term`which is nested inside a parent term.`Term`is replaced with`Replacement`.`Guard`is placed as a conjunction before the parent term.`Guard`typically binds`Replacement`in some useful fashion.For example, a function macro which doubles its argument might expand this

user:function_expansion(double(X), Y, Y is 2*X). main :- V = 9, format('~p times 2 is ~p~n', [V, double(V)]).

into this == main :- V = 9, A is 2*V, format('~p times 2 is ~p~n', [V, A]). == Mathematical constants might be implemented like == user:function_expansion(pi, 3.14159, true). ==

- user:
**function_expansion**`(+Term, -Replacement, -Guard)`is**semidet** -
Like term_expansion/2, function_expansion/3 provides for macro expansion of Prolog source code. In this case, by expanding

`Term`which is nested inside a parent term.`Term`is replaced with`Replacement`.`Guard`is placed as a conjunction before the parent term.`Guard`typically binds`Replacement`in some useful fashion.For example, a function macro which doubles its argument might expand this

user:function_expansion(double(X), Y, Y is 2*X). main :- V = 9, format('~p times 2 is ~p~n', [V, double(V)]).

into this == main :- V = 9, A is 2*V, format('~p times 2 is ~p~n', [V, A]). == Mathematical constants might be implemented like == user:function_expansion(pi, 3.14159, true). ==

- user:
**function_expansion**`(+Term, -Replacement, -Guard)`is**semidet** -
`Term`which is nested inside a parent term.`Term`is replaced with`Replacement`.`Guard`is placed as a conjunction before the parent term.`Guard`typically binds`Replacement`in some useful fashion.For example, a function macro which doubles its argument might expand this