Example



next up previous WS Presentations Main Page
Next: Example Up: Document: ciao Previous: Some Basic Control-Related

Example

:- module(user,[mmultiply/3],ciao(q)).
:- entry(mmultiply(g,g,f)).

mmultiply([],_,[]).
mmultiply([V0|Rest],V1,[Result|Others]) :-
        multiply(V1,V0,Result),
        mmultiply(Rest,V1,Others).

multiply([],_,[]).
multiply([V0|Rest],V1,[Result|Others]) :-
        vmul(V0,V1,Result),
        multiply(Rest,V1,Others).

vmul([],[],0).
vmul([H1|T1],[H2|T2],H1 * H2 + Result) :-
        vmul(T1,T2,Result).



Thu Jan 18 11:29:48 MET 1996 <herme@fi.upm.es>-<webmaster@clip.dia.fi.upm.es>