Plaster
New
List
Login
common-lisp
default
phoe
2020.11.14 17:40:11
(loop with converged = nil for iteration from 0 to iteration-limit until converged do (setf converged t) (loop for document in documents do (unless (convergedp (rank document) (setf (rank document) (loop for neighbor in (graph-neighbors document) sum (/ (* damping (rank neighbor) (document-similarity document neighbor)) (graph-neighbor-edge-sum neighbor))))) (setf converged nil))))
Raw
Annotate
Repaste
Annotations
common-lisp
default
phoe
2020.11.14 17:41:58
(loop with converged = nil for iteration from 0 to iteration-limit until converged do (setf converged t) (loop for document in documents for old-rank = (rank document) for new-rank = (loop for neighbor in (graph-neighbors document) sum (/ (* damping (rank neighbor) (document-similarity document neighbor)) (graph-neighbor-edge-sum neighbor))) do (setf (rank document) new-rank) unless (convergedp old-rank new-rank) do (setf converged nil) ()))
Raw
Repaste
text
default
phoe
2020.11.14 17:43:19
(loop named convergence for iteration from 0 to iteration-limit do (loop for document in documents for old-rank = (rank document) for new-rank = (loop for neighbor in (graph-neighbors document) sum (/ (* damping (rank neighbor) (document-similarity document neighbor)) (graph-neighbor-edge-sum neighbor))) do (setf (rank document) new-rank) when (convergedp old-rank new-rank) do (return-from convergence)))
Raw
Repaste
common-lisp
default
phoe
2020.11.14 17:45:55
(flet ((compute-new-rank (document) (loop for neighbor in (graph-neighbors document) sum (/ (* damping (rank neighbor) (document-similarity document neighbor)) (graph-neighbor-edge-sum neighbor))))) (loop named convergence for iteration from 0 to iteration-limit do (loop for document in documents for old-rank = (rank document) for new-rank = (compute-new-rank document) do (setf (rank document) new-rank) when (convergedp old-rank new-rank) do (return-from convergence t))))
Raw
Repaste
text
default
anonymous
2020.11.14 18:43:35
(flet ((compute-new-rank (document) (loop for neighbor in (graph-neighbors document) sum (/ (* damping (rank neighbor) (document-similarity document neighbor)) (graph-neighbor-edge-sum neighbor))))) (block convergence (dotimes (i limit) (dolist (document documents) (let ((old-rank (rank document)) (new-rank (compute-new-rank document))) (setf (rank document) new-rank) (when (convergedp old-rank new-rank) (return-from convergence t)))))))
Raw
Repaste
Edit