09/07/15 11:02:01
>>478
% Prolog URLリンク(nojiriko.asia)
t478(N,Infile1,Infile2,Outfile) :-
get_lines(Infile1,L1),
get_lines(Infile2,L2),
findall(F1,(member(A1,L1),atom_to_term(A2,F1,_)),_フィルタならび),
findall(F2,(member(A2,L2),atom_to_term(A2,F2,_)),_サンプルならび),
畳み込み和(N,_フィルタならび,_サンプルならび,_畳み込み和),
畳み込み和出力(Outfile,_畳み込み和).
畳み込み和(N,_フィルタならび,_サンプルならび,_畳み込み和) :-
length(L,N),
append(L,_,_サンプルならび),
reverse(_サンプルならび,_逆順サンプルならび),
畳み込み和の二(_フィルタならび,_逆順サンプルならび,_畳み込み和).
畳み込み和の二([],_,0.0) :- !.
畳み込み和の二([A|R1],[B|R2],X) :-
畳み込み和の二(R,R2,Y),
X is A * B + Y.
畳み込み和出力(Outfile,_畳み込み和) :-
open(Outfile,write,Output),
write_formatted(Output,'%t\n',[_畳み込み和]),
close(Output).