Advertisement
Guest User

Untitled

a guest
May 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.88 KB | None | 0 0
  1. (defun hi (a)
  2.   (let
  3.     ((frequenceX (make-list (array-dimension a 0)))
  4.      (frequenceY (make-list (array-dimension a 1)))
  5.      (sum 0))
  6.     (dotimes (i (array-dimension a 0))
  7.        (dotimes (j (array-dimension a 1))
  8.          (progn (setf (elt frequenceX i) (+ (elt frequenceX i) (aref a i j)))
  9.                 (setf (elt frequenceY j) (+ (elt frequenceX j) (aref a j i))))))
  10.      (dotimes (i (array-dimension a 0))
  11.        (dotimes (j (array-dimension a 1))
  12.          (incf sum (/ (* (aref a i j) (aref a i j)) (* (elt frequenceX i) (elt frequenceY j))))))
  13.      sum))
  14.  
  15. (hi (make-array '(10 10) :initial-contents
  16.                     '((0 0 0 1 1 2 1 1 0 1)
  17.                       (1 0 0 4 2 4 3 2 1 0)
  18.                       (0 3 3 8 11 7 4 2 1 0)
  19.                       (2 5 5 12 14 17 11 2 1 2)
  20.                       (4 3 6 21 21 13 10 8 3 1)
  21.                       (1 5 12 13 23 25 7 5 5 1)
  22.                       (3 7 5 16 8 13 12 2 1 0)
  23.                       (0 5 8 9 4 5 4 1 1 0)
  24.                       (0 0 2 2 3 4 0 1 0 0)
  25.                       (1 0 6 2 1 1 2 0 0 0))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement