Created
December 4, 2018 11:59
-
-
Save collinalexbell/57a12666ae0a5947485bbe40f6114ffd to your computer and use it in GitHub Desktop.
just a twitter joke that took a long time to write
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
(defpackage :twitter-karma | |
(:use :cl)) | |
(in-package :twitter-karma) | |
(defun get-twitter-karma () | |
(format t "twitter karma improves your life and the world.") | |
(feel-satisfied-with-tweet (initialize-bad-tweet))) | |
(defun feel-satisfied-with-tweet (tweet-to-rewrite) | |
(rewrite-my-bad-tweet 10 tweet-to-rewrite)) | |
(defun initialize-bad-tweet () | |
(format t "tweets are hard. write a bad tweet now:~%:") | |
(get-new-code)) | |
(defun get-new-code () | |
(format t "place new code in newcode.lisp: press <enter> when done") | |
(read-line) | |
(file->string "newcode.lisp")) | |
(defun file->string (path) | |
(with-open-file (stream path) | |
(let ((data (make-string (file-length stream)))) | |
(read-sequence data stream) | |
data))) | |
(defun rewrite (code) | |
(with-open-file (old-code "oldcode.lisp" :direction :output) | |
(format old-code "~a" code))) | |
(defun rewrite-my-bad-code (times code) | |
(cond ((> times 0) (rewrite-bad-code (- 1 times) (rewrite code))) | |
(t code))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment