Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Implementation of SUM operation
- */
- /* call sum for every element of row */
- sumOperation(L1,L2,SUM):-!,maplist(sumRows,L1,L2,SUM).
- /* sum elements */
- sumRows(H1,H2,H):-!,H is H1+H2.
- /* main SUM function */
- sum(SET1,SET2,SUM):-!,
- rowCount(SET1,RS1),
- rowCount(SET2,RS2),
- colCount(SET1,CS1),
- colCount(SET2,CS2),
- (RS1 == RS2 -> /* same column and row count for sum */
- (CS1 == CS2->
- maplist(sumOperation,SET1,SET2,SUM); /* map operation for every row of matrixes */
- SUM=false);
- SUM=false).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement