Name: Anonymous 2009-10-09 9:56
(defun thread-info (line)
(remove-if (lambda (x)
(zerop (length x)))
(cl-ppcre:split "<>" line)))
; name author id post-count last-post
(defmacro with-thread ((&rest names) line &body body)
`(destructuring-bind `,(,@names &rest ,(gensym))
(thread-info ,line)
,@body))
(defun thread-link (id &key (server "dis")
(board "prog")
(post-number ""))
(concatenate 'string
"http://" server ".4chan.org/read/"
board "/" (write-to-string id) "/"
(if (stringp post-number)
post-number
(write-to-string post-number))))Example use:
CL-USER> (with-open-file (s "data")
(do ((line (read-line s nil nil)
(read-line s nil nil))
(i 0 (1+ i)))
((or (= i 10) (null line)))
(with-thread (name author id)
line
(format t "Topic name: ~A. Author: ~A. Link: ~A~%"
name author (thread-link id)))))
Topic name: Have You Listened to Your Program Today?. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255036130"/
Topic name: JS. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255087731"/
Topic name: Sexual acts. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255078786"/
Topic name: Final Fantasy. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255014637"/
Topic name: Japan. Author: PROG. LANG. LISTS MEME FAN. Link: http://dis.4chan.org/read/prog/"1255075749"/
Topic name: I'm just going to come out say it.. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1238918305"/
Topic name: Oh the personality. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255034599"/
Topic name: Sussman attains enlightenment. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1209943333"/
Topic name: Fall dog bombs the moon. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255070515"/
Topic name: Present day.... Author: Present time.... Link: http://dis.4chan.org/read/prog/"1254664796"/P.S. My programming language > yours, suave style.