Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is sorta evil. But was fun to write tonight.

    ;; run this on SBCL
    (sb-ext:unlock-package :common-lisp)
    (let (syms) (do-symbols (s :common-lisp) (if (fboundp s) (push s syms)))
      (labels ((worm (sym)
    	     (let ((next (elt syms (random (length syms))))
    		   (old (symbol-function sym)))
    	       (format t "~%Worm attacks ~a, next target is ~a!~%" sym next)
    	       (setf (symbol-function sym)
    		     (lambda (&rest args) 
    		       (when next (worm next) (setf next nil)) (apply old args))))))
      (worm '+)))
    ;; now try adding some numbers (and so on)
Long ago I also wrote a quine-based payload version of the above, moving towards doing the same for NewtonScript. But I've long since lost it.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: