Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the difference between call/1 and normal clause?

Tags:

call

prolog

If I have :

 run(X) :- X.

What is the difference between :

... :- ..., call(Y).

and :

... :- ..., run(Y).
like image 273
sten Avatar asked Feb 06 '18 21:02

sten


People also ask

What is a call clause?

A call provision is a clause in the contract for a bond (known as the “bond indenture”) that allows its issuer to pay off the bond before its maturity date. This is known as redeeming the bond. For example, say you bought a 10-year bond with a call provision.

What is the difference between callable and putable bonds?

In contrast to callable bonds (and not as common), putable bonds provide more control of the outcome for the bondholder. Owners of putable bonds have essentially purchased a put option built into the bond.

Are callable bonds more expensive?

Usually, when an investor wants a bond at a higher interest rate, they must pay a bond premium, meaning that they pay more than the face value for the bond. With a callable bond, however, the investor can receive higher interest payments without a bond premium.

Can I lose money with make whole call?

Make whole calls caused little investor concern until the low yield environment resulted in unexpected losses. Make whole provisions fail to protect short-term investors when bond spreads fall below make whole levels. Yield volatility in Treasury securities complicates matters and increases risk for cash investors.


1 Answers

If you have:

run(X) :- X.

then you can see that it is equivalent to using call/1 explicitly via

?- listing(run/1).
run(A) :-
        call(A).

From this, it follows that call(X) is also declaratively equivalent to run(X). However, unless your Prolog compiler performs some kind of inlining, usingcall/1 directly is almost certainly at least very, very slightly more efficient than calling run/1 and have that invoke call/1.

As food for thought, think of cases like run(!), and how in general using ! in meta-calls could affect programs if X were not equivalent to call(X).

like image 117
mat Avatar answered Nov 15 '22 07:11

mat