An easy way is to use Prolog syntax in the data file, i.e., you can
have file vector1 which contains:
1.
3.
2.
and file vector2 which contains
3.
5.
7.
and then you can simply use file_terms/2 from the library:
:- module(_,_).
:- use_module(library(file_utils)).
main :-
file_terms(vector1, V1),
file_terms(vector2, V2),
write('V1 = '), write(V1), nl,
write('V2 = '), write(V2), nl,
v_dot_prod(V1,V2,VP),
write('VP = '), write(VP), nl.
v_dot_prod([],[],0).
v_dot_prod([ V1El | V1Rest ], [ V2El | V2Rest ], VP) :-
v_dot_prod(V1Rest, V2Rest, VPRest),
VP is V1El * V2El + VPRest.
Hope this helps!
--
----------------------- The Ciao System Development Team --------------------
The CLIP Group | Technical University of Madrid
ciao(a)clip.dia.fi.upm.es | University of New Mexico
http://www.cliplab.org /
http://www.ciaohome.org
-----------------------------------------------------------------------------
==============================================================================
Message: Address: Action:
help majordomo(a)clip.dia.fi.upm.es Info. on useful commands
subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list
unsubscribe ciao-users-request(a)clip.dia.fi.upm.es Unsubscribe from this list
<whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list
-----------------------------------------------------------------------------
Archived messages:
http://www.clip.dia.fi.upm.es/Mail/ciao-users/
-----------------------------------------------------------------------------