Last active
August 29, 2015 13:56
-
-
Save wildermuthn/9061083 to your computer and use it in GitHub Desktop.
Testing in LISP is amazing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun make-edge (from ids &key end) | |
(progn | |
(setf ids (mklist ids))) | |
(dolist (to ids) | |
(let ((lst (gethash from *edges*))) | |
(cond ((not lst) | |
(setf (gethash from *edges*) (list to))) | |
(t (if (not (member to lst)) | |
(setf (gethash from *edges*) (append lst (list to))))))) | |
(unless end (make-edge to from :end t))))) | |
; (make-edge 1 3) | |
; (make-edge 3 4) | |
; (make-edge 6 7) | |
; (make-edge 5 '(7 8 9)) | |
(defun print-hash-entry (key value) | |
(format t "The value associated with the key ~S is ~S~%" key value)) | |
;; (maphash #'print-hash-entry *edges*) | |
(defun get-edges (id) | |
(gethash id *edges*)) | |
; (get-edges 1) | |
(defun get-node-edges (edges) | |
(let ((lst '())) | |
(dolist (e edges) | |
(push (get-node e) lst)) | |
lst)) | |
;; (get-node-edges (get-edges 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment