rotate(X):-
write('convert -rotate 90 '),write(X),write(' o.jpg'),
writeln(0).
beside(X,Y):-
write('convert -scale 50%%x50%% '),write(X),writeln(' 0111.jpg'),
write('convert -scale 50%%x50%% '),write(Y),writeln(' 01121.jpg'),
write('convert +append '),write(X),write(Y),writeln(' o.jpg').
above are my prolog codes for rotate and beside functions. How can i modify the codes to suit case like rotate(beside(X,Y)). which are nested
You can't. That's because rotate and beside are not functions, they are predicates.
Functions return values and so you nest them – use the return value of one function as an input of another function. On the other hand, when you try to evaluate a predicate in Prolog, it tries to “unify” all its unbound parameters using the rules you gave it, and returns whether that succeeded and how.
Code like rotate(beside(X,Y)). is valued, but it doesn't mean what you think. It tries to evaluate the predicate rotate on a structure beside(X,Y). It doesn't try to evaluate the beside predicate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With