Anonymous user
Matrix multiplication: Difference between revisions
→{{header|Common Lisp}}
(Added BBC BASIC) |
|||
Line 797:
The following version uses 2D arrays as inputs.
<lang lisp>
(defun mmul (a b)
(loop
with m
with n
with c =
for i below m
sum (* (aref a i j)
C))</lang>▼
(aref b j k)))))
finally (return c)))
;; Example use:
(mmul #2a((1 2) (3 4)) #2a((-3 -8 3) (-2 1 4)))
;; gives: #2A((-7 -6 11) (-17 -20 25))
=={{header|D}}==
|